ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Developing and using .NET assemblies
  • Overview
  • Creating a .NET assembly from a WINDEV project
  • Generating C# classes from WINDEV classes
  • Tips for optimizing the code of classes
  • Types of parameters and types of return values
  • "Input/Output" parameters
  • Consequence: an easier assembly code
  • Creating the setup program of a .NET assembly
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, you must check the configuration of the development computer.
Creating a .NET assembly from a WINDEV project
To create a .NET assembly:
  1. Open the WINDEV project from which the .NET assembly must be created.
    This project must contain all the elements required by the .NET assembly. This project can for example contain one or more global procedures and/or classes, containing various methods. These methods and/or procedures will be the entry points of the assembly.
    Remark: The .NET assemblies intended to be used in other environments should be documented. This documentation is automatically generated by WINDEV.
  2. If necessary, create a ".NET assembly" project configuration.: on the "Project" tab, in the "Project configuration" group, expand "New configuration" and select ".NET assembly DLL". In the wizard, specify:
    • the name and description of the project configuration.
    • the elements included in the project configuration.
    • Validate. The project configuration is created with the necessary elements.
  3. In the quick access buttons, click to generate the .NET assembly. The .NET assembly creation wizard starts.
  4. Specify the properties of the .NET assembly that will be created: file name, company, description, copyright, etc.

    The "Advanced" button is used to define the additional properties specific to the .NET assembly.
  5. Specify the version number. Two formats are available for the version numbers:
    • Standard format. This format is the standard format managed by Windows. This format corresponds to a set of 4 numbers separated by dots.
      • The first group of 4 digits corresponds to the number of major changes performed in the application.
      • The second group of 4 digits corresponds to the number of minor changes performed in the application.
      • The third group of 4 digits corresponds to the generation number.
        We advise you to automatically increment this number at each generation. This increment operation is automatically performed if the option "Automatically increment the version at each generation" is checked.
      • The last group of 4 digits corresponds to the number of reviews (branches in the SCM for example).
    • Format for compatibility. This format was used until version 12 for the WINDEV applications.
      Remark: All the characters (digits and letters) are allowed. For example: "1.01A".
      If "Automatically increment the version at each generation" is checked, the version number will be modified at each generation: the version number "1.01A" will become "1.01B" and the version number "A14Z" will become "A15A".
  6. Select the different WINDEV elements (project, windows, classes, ...) that will be included in the .NET assembly.
    • The "Add" button is used to add an element to the .NET assembly: images, text files, etc.
    • The "Remove" button is used to delete an element from the .NET assembly. The corresponding files and their dependencies will not be included in the.NET assembly.
    • The "WDU" button is used to display the elements found in a library that was created beforehand.
      Remark: If the WINDEV project (".WDP" file) is selected:
      • the project analysis will be associated with the.NET assembly.
      • the project initialization event will be executed when the .NET assembly is initialized.
      • the project closing event will be executed when the .NET assembly is closed.
  7. Select the WINDEV classes (".WDC" files) and sets of procedures (".WDG" file) that will be made accessible. These classes and these sets of procedures can be handled from the application that will use the .NET assembly.
    A public class of the assembly must have a constructor without parameter (or with optional parameters).
    All the classes that are instantiated in a public class of the assembly must also be public.
    Remark: A .NET class is generated with the name of the set of procedures. This .NET class contains:
    • a static function corresponding to each function of the set of procedures.
    • a static member corresponding to each variable of the set of WINDEV procedures.
  8. Select:
    • the target .NET Framework version.
    • the WINDEV framework (32 or 64-bit) to be provided with the .NET assembly.
  9. Select the libraries of the WINDEV Framework required for your assembly to operate.
    Remarks:
    • WINDEV Framework libraries corresponding to .NET (wd290netx.dll, for example) cannot be renamed.
    • Some project configurations must be used if the same project allows you to generate several versions of the same assembly.
    • Two .NET assemblies must be generated in WINDEV if a .NET assembly must run in 32-bit and a 64-bit version. The same assembly cannot run on 32-bit and 64-bit versions.
  10. Configure the error message if necessary. This message will be displayed if an error occurs when using the .NET assembly.
    The "Default" button allows you to configure a default error message.
  11. Select the options specific to the assembly:
    • The "Compilation options" button is used to select a specific C# compiler and to specify some additional compilation options.
    • The "Advanced properties" button is used to define whether the .NET assembly must be accessible by a program that uses the COM technology. For more details, see Creating a .NET assembly that can be accessed using COM.
  12. Validate.
The .Net assembly is generated in the EXE directory of the project as well as an XML document containing the documentation about the assembly.
Remarks:
  • The assemblies generated by WINDEV can be used like any other .NET assembly. However, the WINDEV framework and the assembly must be found in the same directory.
  • Limitation: The reports and the queries do no operate in the .NET assemblies.
  • The .Net assemblies generated by WINDEV have a single execution context: therefore, they can be run by a single thread.
Generating C# classes from WINDEV classes

Tips for optimizing the code of classes

Tips for optimizing the code of the generated classes are presented below. In your WINDEV classes:
  • Type the parameters of methods and the return values.
  • Use the "LOCAL" keyword in order for the parameters of methods not to be "Input/Output" parameters.
  • Replace the reserved words of C#.
  • Eliminate the multiple inheritances.

Types of parameters and types of return values

The available types are those of WLanguage.
If the types of parameters are not specified in the prototype of the method, they are automatically defined by WINDEV. In this case, the .NET assembly generator uses the "Object" type.

"Input/Output" parameters

If the LOCAL keyword is not used in the parameter declaration in the function prototype, the parameter is considered in "Input/Output" (the assembly generator uses the "ref" keyword).

Consequence: an easier assembly code

When exporting a standard WLanguage class, all the parameters are non-typed and in Input/Output.
If the above-mentioned optimizations are not performed, the assembly generator generates functions that accept "ref object" parameters, which makes the program that uses the assembly more complex.
Indeed, to pass a "ref object" parameter to a function (in C# for example), you must:
  1. Create an "Object".
  2. Copy the type variable of C# into this "object".
  3. Pass by reference an "Object" in parameter to the method of the WLanguage class.
Creating the setup program of a .NET assembly
The setup program for a.NET assembly is created as any other setup program for a standard WINDEV application.
To create the setup program of a .NET assembly:
  1. In the quick access buttons, select the generation mode "Create the setup procedure of the assembly".
  2. Follow the instructions of the wizard.
Remark: The assemblies generated by WINDEV can be used like any other .NET assembly. However, the WINDEV framework and the assembly must be found in the same directory.
Related Examples:
WD Using DOTNET Training (WINDEV): WD Using DOTNET
[ + ] This example converts currencies into other currencies.
The base of this project (the cEuro class) is used to create a.Net assembly
WD Using.NET is presented:
1/ As a WINDEV project and an assembly (all working without.Net in test mode)
2/ As a.Net project written in  C# and a.Net executable
Summary of the example provided with WINDEV:
Now you can use.Net assemblies in WINDEV and you can generate.Net assemblies from WINDEV!
Minimum version required
  • Version 9
Comments
Exemplo
https://forum.pcsoft.fr/fr-FR/pcsoft.br.windev/3763-windev-desenvolvendo-dll-assembler-net-32-64-usando-3764/read.awp
Boller
01 Jun. 2021

Last update: 06/23/2023

Send a report | Local help