Developer Center Resources

cancel
Showing results for 
Search instead for 
Did you mean: 

Instantiating .NET Objects from LabVIEW

 

» Calling External Code » .NET Assemblies » Instantiating .NET Objects

 

 

Instantiating .NET Objects from LabVIEW

The .NET Constructor Node (Functions Palette » Connectivity » .NET » Constructor Node) allows you to specify the class that you want to instantiate and its owning assembly. You can pick from the available constructors of the class, and the node will give you a reference to the .NET object. This reference can be wired to .NET Property Nodes and .NET Invoke Nodes to access properties and methods of the class.

 

For example, to create an instance of System.Timers.Timer, you would:

  1. Switch to the Block Diagram
  2. Drop in a Constructor Node (Functions Palette » Connectivity » .NET » Constructor Node)
  3. This will bring up the Select .NET Constructor dialog
    Note: You can bring this dialog up in the future by double clicking on the Constructor Node.
  4. Select the assembly System from the Assembly dropdown box
  5. In the Objects list, expand System.Timers and select the class Timer
    010ConstructorNodeDialog.png

 

 

Destroying .NET Objects from LabVIEW

When you are done using a .NET Object, you should destroy it to free up any resources associated with the object. To destroy a .NET object, wire in the object reference to the Close Reference VI (Functions Palette » Connectivity » .NET).

018DestroyTimer.png

Examples & References

The following examples install with LabVIEW:
Calculator VI: labview\examples\comm\dotnet\Calculator.llb
SimpleTaskMonitor VI: labview\examples\comm\dotnet\SimpleTaskMonitor.llb

 

 

Community Example: Calling .NET Assemblies from LabVIEW

LabVIEW Help: .NET Functions

 

Jervin Justin
NI TestStand Product Manager