LabWindows/CVI

Structure of the Generated .NET Assembly Wrapper

Use the Create LabWindows/CVI .NET Controller dialog box to generate a LabWindows/CVI wrapper for a .NET assembly. LabWindows/CVI generates the wrapper in the form of an instrument driver, source file, and header file. You also can use the LabWindows/CVI .NET Library functions in conjunction with the generated wrapper when calling a .NET assembly.

Each function class within the generated instrument driver corresponds to a .NET type in the assembly. Within each function class, LabWindows/CVI generates functions corresponding to the .NET type constructors, methods (including static methods), properties, and fields.

LabWindows/CVI does not generate functions for all .NET entities. LabWindows/CVI generates functions only for .NET entities with public access rights. LabWindows/CVI does not generate functions for protected or private entities.

Default Naming Conventions

LabWindows/CVI uses the following default naming conventions for items in the generated wrappers. The examples in the following table are based upon .NET entities whose namespace is MyNS and type is MyType.

.NET Entity Default Generated Wrapper Function Name(s)
object handle type MyNS_MyType
constructor MyNS_MyType__Create
method: MyMethod MyNS_MyType_MyMethod
read-write property: MyProp get function: MyNS_MyType_Get_MyProp
set function: MyNS_MyType_Set_MyProp
field: MyField get function: MyNS_MyType__Get__MyField
set function: MyNS_MyType__Set__MyField
enum: MyEnum MyNS_MyEnum
enum members: MyValue1, MyValue2 MyNS_MyEnum_MyValue1, MyNS_MyEnum_MyValue1


Note  LabWindows/CVI cannot generate function panels for generated wrapper functions with default names that exceed the maximum length allowed in function panels. You can modify the generated function names in the Create LabWindows/CVI .NET Controller dialog box.

If a .NET type is generic, then the LabWindows/CVI wrapper name for the type is followed by _T and the number of generic parameters of the type. For example, MyNS.MyType<M, N> is represented as MyNS_MyType_T2 in the generated LabWindows/CVI wrapper. Generic methods do not use this naming pattern but rather use the same naming pattern as non-generic methods.

.NET methods can be overloaded. That is, different methods can have the same name. To generate an instrument driver in which each function name is unique, LabWindows/CVI appends an underscore and a unique number to each of the generated functions, except the function generated from the first instance of the method, which is not numbered. For example, if MyMethod is overloaded, LabWindows/CVI generates MyNS_MyType_MyMethod, MyNS_MyType_MyMethod_1, MyNS_MyType_MyMethod_2, and so on for as many methods as share the same name. .NET constructors and properties also can be overloaded and are named using the same convention.

Some .NET assemblies also have get or set methods and get or set properties and fields. You can distinguish between the functions LabWindows/CVI generates for the methods and the functions LabWindows/CVI generates for getting and setting properties or fields by the use of underscores in the generated function name. The names of functions for getting and setting properties include a single underscore before and after "Get" or "Set" in the function name. The names of functions for getting and setting fields include a double underscore before and after "Get" or "Set" in the function name. LabWindows/CVI does not add any underscores around "Get" or "Set" in the names of functions generated for get or set methods.

Included Parameters

There are two kinds of methods, fields, and constructors: static and instance. If an entity is static, it belongs to the entire type. If it is instance, it belongs to an instance of the type. The default function naming scheme does not differ for static versus instance entities. However, the generated wrapper for an instance member includes the instanceHandle parameter as its first parameter, but the generated wrapper function for a static member does not.

When LabWindows/CVI creates a function for a .NET method, it includes the libraryStatus return value and the exceptionHandle parameter to provide status information about the function and underlying method. You can pass the error code to CDotNetGetErrorDescription to get information about the library error. You can pass the exception handle to CDotNetGetExceptionInfo to get information about the thrown exception.

If you generate wrappers for a generic type constructor or a generic method, LabWindows/CVI includes additional string parameters for passing the generic type arguments in the form of .NET type names. Any parameters of the specialized types are typed as void  * in the generated wrapper. Always pass the values for these parameters by reference. The .NET code void Foo<T>(T t) is wrapped as Foo (..., char *T, void *t). The user must pass the value for t by reference. For example, Foo<int>(10) in .NET becomes the following code in C: int t = 10; Foo(..., "System.Int32", &t);.

Help Information

Some .NET assemblies include an XML file that contains help information for the assembly. If the .NET assembly for which you generate a LabWindows/CVI wrapper includes an XML file, LabWindows/CVI displays the appropriate help information in the wrapper function panels and controls. To access this information, right-click a function panel or function panel control. You also can select Help»Function or Help»Control to access this information.

Note  The LabWindows/CVI wrapper generator is designed to handle common XML help tags. If the XML file includes non-standard or vendor-specific XML tags, the help information LabWindows/CVI displays in the wrapper function panels and controls might be incomplete or incorrect.