• 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
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WindowsLinuxPHPWEBDEV - Browser code
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Stored procedures
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 provided 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.
    Remark: 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 to the C:\Windows\Assembly directory
    • Copy the wd280net.dll library to the c:\Windows\Assembly directory (otherwise the instantiation of the COM object will fail with the "file not found at the specified location" error)
    • Check whether wd280vm.dll is in the PATH directory
Remark: 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 version required
  • Version 9
Click [Add] to post a comment