Example: Import .NET GAC Assemblies

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

Home >  Projects and Code Engineering > Importing Java, C# and VB.NET Binaries >

Example: Import .NET GAC Assemblies

This example shows you how to import binary types from the .NET Global Assembly Cache (GAC) into a UModel C# project. The instructions are similar if you want to import binary types from a standalone .dll or .exe file. For a Java example, see Example: Importing Java .class Files.

 

 

To import binary files from the .NET Global Assembly Cache:

1.On the Project menu, click Import Binary Types.

um_import_gac_01

2.Choose the target language of the UModel project (C#, VB.NET, Java). In this example, C# is selected, since we are importing a .NET GAC assembly.
3.If you would like to set a specific language version for the imported UModel project, select it from the adjacent text box. In this example, C# 6.0 is selected.
4.Optionally, select a .NET Framework version from the Runtime drop-down list. This list includes all the .NET Framework versions detected on your machine. UModel will choose one of its built-in reflection APIs depending on your selection. The options .NET Core 2.1 win-x86 and .NET Core 2.1 win-x64 enable you to import binary types targeting the respective versions and platforms of .NET Core.
5.If you import binary types into a new project, select either Merge Code into Model or Overwrite Model according to Code. Otherwise, select Merge code into Model.
6.Optionally, to generate class diagrams and package diagrams from the imported binary types, select the Enable diagram generation check box. If you select this option, more diagram generation options are available in subsequent steps, see also Generating Class Diagrams and Generating Package Diagrams.
7.Click Next.
8.Click Add | Assembly from Global Cache (GAC).

um_import_gac_02

9.Select an assembly from the dialog box. In this example, the "EventViewer" assembly is selected.

um_import_gac_03

10.Select the types to be imported, and click Next.

um_import_gac_04

Notes:

 

The text box Override of PATH variable... is applicable only to Java. Optionally, paste here any Java class paths that must be queried in addition to those read from the CLASSPATH environment variable (or click Add and browse for the required folders).
The check box use 'reflection only' context... is applicable only when you import a C# or VB.NET binary. This is useful when importing a library (dll, etc) which has dependencies that cannot be resolved or loaded. Selecting this check box will also not execute any static initializer code, which might cause errors when importing.

 

11.Select the import options as applicable, see Import Binary Options.
12.If you enabled diagram generation in an earlier step, click Next and configure the options applicable to diagram generation. Otherwise, click Finish.

 

UModel performs the conversion, and displays a progress log in the Messages window. If conversion of binary types was not possible, the error text may provide additional information. For example, it might be the case that the binary file you attempted to import was targeting a runtime newer than the one selected on the "Import Binary Types" dialog box. In this case, try again and select a newer runtime version.


© 2019 Altova GmbH