PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Overview
  • Creating a .NET assembly accessible by COM from a WINDEV project
  • Creating a .NET assembly accessible by COM
  • Using an assembly in a C++ program
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Overview
Before creating a .NET assembly, all the elements required by this assembly must have been developed in a WINDEV project.
Creating a .NET assembly accessible by COM from a WINDEV project

Creating a .NET assembly accessible by COM

To create a .NET assembly accessible by COM, you must:
  1. Create a ".snk" file.
    The snk file contains the "public key/private key" pair used to digitally sign the assemblies created by a company. In most cases, the same snk file is used to sign all the products of a company.
    This file must be kept secret in order to prevent a third party from signing its own assemblies with the same signature.
    To generate an ".snk" file, you must use the generator supplied with the .NET SDK (sn.exe file). The following command line must be used to generate a snk file: "sn.exe -k MySNKFile.snk"

    An example file is supplied with WINDEV, in the "Programs\Data\Example.snk&" directory of the setup directory of WINDEV. This file is used to test the generation of strong-named assemblies.
    Note: this file being distributed with WINDEV, it does not allow you to identify in a unique way the generated assemblies.
  2. Modifying the code of the classes found in the WINDEV project
    • The class must have a constructor without argument (this is the only constructor that can be used by COM)
    • The static members will not be accessible by COM
    • The overloaded methods are renamed in COM
  3. In the wizard for generating.NET assemblies, select the following options:
    • Check "Accessible by COM"
    • Specify the location of the snk file that was created beforehand.
  4. Copy the generated assembly into the directory of shared assemblies of Windows:
    • Copy the assembly into the C:\Windows\Assembly directory
    • Copy the wdxxxnet.dll library into the c:\Windows\Assembly directory (otherwise the instantiation of the COM object will fail with a "file not found at the specified location" error)
    • Check that wdxxxvm.dll is found in the directory of PATH
Note: From Windows Vista, if the UAC is enabled, you may get an error such as "Access denied" during the copy into the "C:\Windows\Assembly" directory. In this case:
  • run the "command prompt" program (cmd.exe) as administrator.
  • use the "gacutil" tool. Example: gacutil.exe -I "c:\My Projects\My Project\Exe\MyAssembly.dll"

Using an assembly in a C++ program

To use an assembly in a C++ program:
Caution: These operations must be repeated whenever loading a GUID of interfaces:
  1. Import the assembly: "regasm MyAssembly.DLL /tlb:MyAssembly.tlb".
  2. Use the tlb file generated in the C++ project.
  3. Recompile the C++ project.
Minimum required version
  • Version 9
Comments
Click [Add] to post a comment