ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Developing and using .NET assemblies
  • Overview
  • Creating a .NET assembly accessible by COM from a WINDEV project
  • Creating a .NET assembly that can be accessed using 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/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
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 that can be accessed using 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 installation 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. Modify the code of the classes 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 "c:\Windows\Assembly".
    • Copy the wd290net.dll library to "c:\Windows\Assembly" (otherwise, the instantiation of the COM object will fail and will throw the "file not found at the specified location" error).
    • Make sure the wd290vm.dll file is in a directory specified in PATH.
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:
  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.
Caution: These operations must be repeated whenever loading a GUID of interfaces
Minimum version required
  • Version 9
Comments
Click [Add] to post a comment

Last update: 08/31/2023

Send a report | Local help