LabWindows/CVI

Content Type
Programming Language
Current manual

.NET Library Overview

.NET Library Overview

The .NET Library contains functions that facilitate calling .NET assemblies. Use the .NET Library in conjunction with the instrument drivers you can generate using the Create LabWindows/CVI .NET Controller dialog box. These instrument drivers are LabWindows/CVI wrappers for .NET assemblies. Select Tools»Create .NET Controller to launch the Create LabWindows/CVI .NET Controller dialog box.

In most cases, it is not necessary to use this library directly, other than to free .NET handles. You can program with most .NET assemblies using only the instrument driver wrapper functions.

(Linux) The functions in the .NET Library are not supported.

Notes  
  • LabWindows/CVI supports Microsoft .NET Framework 4.0 or later. To create a LabWindows/CVI wrapper for a .NET assembly and call it, your computer must have a version of the .NET Framework that is appropriate for your assembly. You can download the .NET Framework from the Microsoft Web site.
  • If you install the .NET Framework after you install LabWindows/CVI, you must then reinstall LabWindows/CVI or repair the existing LabWindows/CVI installation.

.NET Library Functionality

In most cases, you primarily use the generated wrapper functions to program with .NET assemblies in LabWindows/CVI. Use the .NET Library functions for the following tasks:

  • Register assembly paths and load assemblies.
  • Create and call .NET objects.
  • Manage resources.
  • Create .NET arrays, get information about .NET arrays, and get and set .NET array elements.
  • Call the System.Object methods that all .NET objects support.
  • Get error and exception information.
  • Provide information about .NET assembly components.
  • Interoperate with COM objects.
  • Create .NET delegates and handle .NET events.
Note Note  Also, LabWindows/CVI is not a .NET control container. Therefore, you cannot use .NET user interface objects in LabWindows/CVI panels.

Passing Invalid Handles to the .NET Library

Passing invalid addresses or handles that have already been freed can result in the program and system becoming unstable. If you pass an invalid object or assembly handle to the .NET Library, the .NET execution engine can become corrupted. As a result, the execution engine can throw an exception that the library cannot handle, and the system will terminate your program.

Generics

.NET 2.0 and later supports generics, which allow you to create parameterized classes, interfaces, methods, and other .NET entities. You can instantiate or invoke the same generic entity multiple times using different type arguments in each instance.

In .NET, generic entities can have any number of type parameters. When a generic is specialized, each type parameter is replaced by the specified type argument. LabWindows/CVI generates wrappers for generics that include an additional input string parameter for each type parameter. The user can pass a .NET type name for each type parameter to specialize the generic entity.

Note Note  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);.

Registering Assemblies

If you plan to use an assembly in LabWindows/CVI that is not located in the Global Assembly Cache (GAC) or in the current directory of the calling executable, then you must call CDotNetRegisterAssemblyPath to register the assembly. If you use an assembly that is located in the GAC or in the current directory of the calling executable, it is not necessary to call CDotNetRegisterAssemblyPath to use the assembly; the assembly is registered automatically.

Assembly Dependencies

Some .NET assemblies reference types that are defined in other .NET assemblies. If you need full access to these types, you must generate wrappers for the .NET assemblies in which they are defined. If such dependencies exist, the code generator displays a list of the dependencies after it generates the target assembly wrapper. The generated header file also includes comments that indicate which types that are exposed in the target assembly are defined in other assemblies and the locations of those defining assemblies.

Threads

The .NET library is thread-safe, and you can call it concurrently from multiple threads.

Was this information helpful?