Constructor Node

From LabVIEW Wiki
Jump to: navigation, search
Object information
Owning palette(s) .NET
Type Node
Requires Basic Development Environment
Icon Constructor Node.png

The Constructor Node calls the constructor of a .NET class or struct and returns a .NET Refnum to the class instance. When placed on the Block Diagram, the user must select the .NET Assembly, class, and constructor from the Select .NET Framework Constructor Dialog. Depending on the selected constructor, the node may provide zero or more input terminals for the constructor arguments.

Class instances created with the Constructor Node must be disposed with a corresponding call to the Close Reference function.

Starting with LabVIEW 2024 Q3, support for .NET Core 8.0 was added as experimental preview feature that can be enabled through the Preview Features category in the Options dialog.

Select .NET Framework Constructor Dialog

The Select .NET Framework Constructor dialog (previously Select .NET Constructor) provides access to all .NET Framework assemblies in the Global Assembly Cache and manually selected assemblies.

It appears when placing a new Constructor Node on the Block Diagram, double-clicking a Constructor Node, or when selecting the Select .NET Framework Constructor shortcut menu option on a Constructor Node.

Select .NET Core Constructor Dialog

The Select .NET Core Constructor dialog is functionally equivalent to the Select .NET Framework Constructor dialog. However, it provides access to .NET Core assemblies installed by the .NET Runtime and manually selected assemblies.

Best practices

  • Avoid placing custom assemblies in the Global Assembly Cache unless you can ensure that the assemblies are reliably distributed to all developer machines.
  • Place assemblies in your repository next to VIs that call the assembly, or in a relative directory. This ensures that assemblies can be loaded on different machines when checking out the source code.
  • Do not load VIs that link to different versions or copies of the same assembly. This can result in cross-linking and broken VIs when loaded on a different machine.
  • Do not move assemblies that are used by VIs. This can result in situations where a VI appears to be working but is broken when checked-out on a different machine.
  • Do not change the Assembly Version of assemblies unless the assembly is incompatible with the previous version. The assembly version is part of the assembly name used to lookup the assembly. When the assembly version changes, all refnums must be linked to the new version.
  • Avoid breaking changes to public interfaces of your assemblies. This can result in errors that will only be reported when re-compiling VIs.
  • Always clear the compiled object cache when moving assemblies or introducing breaking changes. This ensures that LabVIEW recompiles all VIs and reports any failures.

Trivia

The Constructor Node has a few additional terminals that are undocumented and should not be used in production code:

Constructor Node Trivia (Terminals).png

  • reference (above the error in terminal): This terminal appears to accept any .NET Refnum but its use is unclear.
  • void (middle-left terminal): This terminal is of type void and does not accept any type.
  • type? (middle-right terminal): This terminal appears to return the data type of the chosen class but not the instance (refnum value is always zero).

External links