Example: Import Custom .NET DLL Assembly

www.altova.com Print this Topic Previous Page Up One Level Next page

Home >  Functions > Importing Custom Java and .NET Libraries >

Example: Import Custom .NET DLL Assembly

This example illustrates how to import into MapForce a custom .NET DLL assembly created in C#. The source code of this sample is available at the following path: <Documents>\Altova\MapForce2019\MapForceExamples\C#\Format. The .dll assembly file that will be imported into MapForce is in the ..\bin\Debug directory. You can also open the solution .sln file in Visual Studio and compile a new .dll file using the latest .NET Framework version.


Note:To run this example, .NET Framework 2.0 or later must be installed on your computer. If it's not already enabled, you can enable it from Control Panel > Programs and Features > Turn Windows features on and off > .NET Framework <version>.



To import the .NET assembly file:

1.Set the transformation language to C# (see Selecting a Transformation Language).
2.Click the Add/Remove Libraries button in the lower area of the Libraries window.
3.Next to Libraries, click Add, and select the Format.dll file from the ...\MapForceExamples\C#\Format\bin\Debug\ directory. A message appears telling you that a new library has been added. The imported library is now visible in the Libraries window.



To preview the mapping output:

1.Open the FormatNumber.mfd file available in the ...\MapForceExamples\C# folder.
2.Click the Output button to see the result of the mapping.




To run the mapping from a custom C# application:

1.On the File menu, click Generate Code In | C#.
2.Select a target directory where the code should be generated, and click OK.
3.Build the application with Visual Studio, and run the generated console application (see also Generating C# code).

© 2019 Altova GmbH