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
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
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.
    Note: this file being distributed with WINDEV, it does not allow you to uniquely identify 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 wd300net.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 wd300vm.dll file is in a directory specified in PATH.
Note: If Windows UAC is enabled, you may get an "Access denied" error when copying data to "C:\Windows\Assembly". 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 following assembly: "regasm MyAssembly.DLL /tlb:MyAssembly.tlb".
  2. Use the tlb file generated in the C++ project.
  3. Recompile the C++ project.
Caution: These actions must be performed each time the GUID of the interfaces changes
Minimum version required
  • Version 9
Comments
Click [Add] to post a comment

Last update: 09/26/2024

Send a report | Local help