| |
com_module_sample_vs [2018/06/08 05:37] – created wolfgangriedmann | com_module_sample_vs [2018/06/08 05:40] (current) – wolfgangriedmann |
---|
X# | X# |
| |
- Prepare a GUID | * Prepare a GUID |
| |
The GUID is a unique number and one can be created at https://www.guidgenerator.com/online-guid-generator.aspx. | The GUID is a unique number and one can be created at https://www.guidgenerator.com/online-guid-generator.aspx. |
587BF093-A8F9-4119-12EB-414AA8FCF344 | 587BF093-A8F9-4119-12EB-414AA8FCF344 |
| |
- Create a new X# Class library in Visual Studio or Xide. I call the namespace DotNetLibForVO and the class VoDotNetClass | * Create a new X# Class library in Visual Studio or Xide. I call the namespace DotNetLibForVO and the class VoDotNetClass |
| |
In the startprogram after BEGIN NAMESPACE add the following 3 lines, with the generated guid from above. Note that there are no empty lines in between. The code then looks as follows: | In the startprogram after BEGIN NAMESPACE add the following 3 lines, with the generated guid from above. Note that there are no empty lines in between. The code then looks as follows: |
RETURN</code> | RETURN</code> |
| |
- Add methods. Here's a working sample: a method to get a file (e.g. one copied to the %temp% directory) in the clipboard, which is not (easily) possible from VO. | * Add methods. Here's a working sample: a method to get a file (e.g. one copied to the %temp% directory) in the clipboard, which is not (easily) possible from VO. |
<code>METHOD SaveImageFromClipboard(cFile AS STRING) AS LOGIC | <code>METHOD SaveImageFromClipboard(cFile AS STRING) AS LOGIC |
//#s Save jpg cFile from clipboard DvK 15-9-2014 | //#s Save jpg cFile from clipboard DvK 15-9-2014 |
RETURN lCreated</code> | RETURN lCreated</code> |
| |
- Make sure to compile in Release mode otherwise your registration will fail. Compile your DLL and make sure that all depending DLL's in the Release directory are copied in the VO program directory. | * Make sure to compile in Release mode otherwise your registration will fail. Compile your DLL and make sure that all depending DLL's in the Release directory are copied in the VO program directory. |
- Click on DotNetLibForVO, right mouse button, Properties | * Click on DotNetLibForVO, right mouse button, Properties |
- In Build Events (VS: click Edit Post-build) : | * In Build Events (VS: click Edit Post-build) : |
| |
Enter the 3 lines below on Post build Event Comment Line. Note that you may need to check the exact location of mt.exe and make sure that you do not use the mt.exe in x86 if you are on a 64 bits Windows. This should work too: | Enter the 3 lines below on Post build Event Comment Line. Note that you may need to check the exact location of mt.exe and make sure that you do not use the mt.exe in x86 if you are on a 64 bits Windows. This should work too: |
At Run the post-build event choose: On successful build | At Run the post-build event choose: On successful build |
| |
- Build the project. The manifest is now being created the project directory, (DotNetLibForVO.manifest). The DLLs are copied top the directory indicated. Then edit again the Post Build events by adding the REM in the first line so it won't be executed again. Build once more. Your DLL should now contain the manifest info. | * Build the project. The manifest is now being created the project directory, (DotNetLibForVO.manifest). The DLLs are copied top the directory indicated. Then edit again the Post Build events by adding the REM in the first line so it won't be executed again. Build once more. Your DLL should now contain the manifest info. |
| |
VO | VO |
| |
- Retrieve c: \ cavo29 \ Appwiz \ cctl6.man, modify the program name, set the version number to 2.0.0.0 and add the relevant part of the generated manifest code as Dependency (see example above) and save it in a directory of your choice e.g. c:\VoManifests. For the X# DLL make sure that processorArchitecture = "msil (and not" * ") | * Retrieve c:\cavo28\Appwiz\cctl6.man, modify the program name, set the version number to 2.0.0.0 and add the relevant part of the generated manifest code as Dependency (see example above) and save it in a directory of your choice e.g. c:\VoManifests. For the X# DLL make sure that processorArchitecture = "msil (and not" * ") |
- Add a module Manifest containing RESOURCE CREATEPROCESS_MANIFEST_RESOURCE_ID RC_RT_MANIFEST c:\VoManifests\DotNetLibForVO.manifest. Note that after every change in the manifest you should touch the manifest mef and select Rebuild All for the VO Applications . E.g.: | * Add a module Manifest containing RESOURCE CREATEPROCESS_MANIFEST_RESOURCE_ID RC_RT_MANIFEST c:\VoManifests\DotNetLibForVO.manifest. Note that after every change in the manifest you should touch the manifest mef and select Rebuild All for the VO Applications . E.g.: |
| |
RESOURCE CREATEPROCESS_MANIFEST_RESOURCE_ID RC_RT_MANIFEST c:\VoManifests\ChosenName.manifest | RESOURCE CREATEPROCESS_MANIFEST_RESOURCE_ID RC_RT_MANIFEST c:\VoManifests\ChosenName.manifest |
</assembly></code> | </assembly></code> |
| |
- To use a method from the library, write code in VO like the code below. For OleAutoObject you use, between {"Namespacename.Classname"} (as chosen in 1) | * To use a method from the library, write code in VO like the code below. For OleAutoObject you use, between {"Namespacename.Classname"} (as chosen in 1) |
| |
<code>METHOD PasteImage () CLASS Something | <code>METHOD PasteImage () CLASS Something |
Note that the architecture In yellow is what Windows found in the manifest and in blue what was found in the DLL (from the project settings in e.g. VS). The manifest line in 8), see in blue, must match the one in the DLL, otherwise this error occurs. | Note that the architecture In yellow is what Windows found in the manifest and in blue what was found in the DLL (from the project settings in e.g. VS). The manifest line in 8), see in blue, must match the one in the DLL, otherwise this error occurs. |
| |
- For more info on the error there's one of those terrible command line tools from Microsoft, SX Trace | * For more info on the error there's one of those terrible command line tools from Microsoft, SX Trace |
| |
SXTrace | SXTrace |
Administrative privileges are required to use sxstrace.exe | Administrative privileges are required to use sxstrace.exe |
| |
- Open Command Prompt (Admin) | * Open Command Prompt (Admin) |
- Start SxSTrace by running the command: sxstrace.exe Trace -logfile:tracetest.log | * Start SxSTrace by running the command: sxstrace.exe Trace -logfile:tracetest.log |
Note: Make sure you run the command on a directory with write permissions. As an alternative, point the –logfile parameter to a directory with write permissions | Note: Make sure you run the command on a directory with write permissions. As an alternative, point the –logfile parameter to a directory with write permissions |
- Run the program causing the error message (from Explorer or another prompt). When the error message appears click OK | * Run the program causing the error message (from Explorer or another prompt). When the error message appears click OK |
- Stop Trace (by pressing Enter in the DOS box) | * Stop Trace (by pressing Enter in the DOS box) |
- Convert log to readable format. The tracetest.log from above is a binary formatted file. This command will convert into human readable format by parsing the binary log file and creating a text file | * Convert log to readable format. The tracetest.log from above is a binary formatted file. This command will convert into human readable format by parsing the binary log file and creating a text file |
sxstrace.exe Parse -logfile:tracetest.log -outfile:tracetest.txt | sxstrace.exe Parse -logfile:tracetest.log -outfile:tracetest.txt |
| |
| |
Sample: courtesy by Dick van Kooten | Sample: courtesy by Dick van Kooten |
| |
| |