- 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
Creating a .NET assembly from WINDEV
Creating a .NET assembly from a WINDEV project
To create a .NET assembly:
- 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.
- In the quick access buttons, select the generation mode "Generate a .NET assembly":
Remark: If you did not create a project configuration specific to the creation of a .NET assembly, the wizard for creating a project configuration starts. To optimize the organization of your projects, we advise you to use the project configurations. For more details, see Project configuration.
In this case, the wizard requests:
- the name and description of the project configuration.
- the elements included in the project configuration.
Then, the wizard for generating a .NET executable starts.
- The wizard for creating a .NET assembly starts.
- Specify the properties of the .NET assembly that will be created: file name, company, description, copyright, ...
The "Advanced" button is used to define the additional properties specific to the .NET assembly.
- 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".
- 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 into 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 initialization process of the project will be run when the .NET assembly is initialized.
- the ending process of the project will be run when closing the .NET assembly.
- 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.
- Select the version of the .NET Framework to use as well as the WINDEV Framework (32-bit or 64-bit) that will be supplied with the .NET assembly. Select the libraries of the WINDEV Framework required for your assembly to operate.
- The libraries of the WINDEV Framework corresponding to .NET (wdxxxnetx.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 operate in 32 bits and in 64 bits. The same assembly cannot operate in 32 bits and in 64 bits.
- 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.
- 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 Create a .NET assembly accessible by COM.
The .Net assembly is generated in the EXE directory of the project as well as an XML document containing the documentation about the assembly.
- 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 runtime 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 generator of .NET assembly is using the "Object" type.
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:
- Create an "Object".
- Copy the type variable of C# into this "object".
- 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:
- In the quick access buttons, select the generation mode "Create the setup procedure of the assembly":
- Follow the instructions given by 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.
Training (WINDEV): WD Using DOTNET