Assigning Values to Object References

TestStand 2019 Help

Edition Date: May 2019

Part Number: 370052AA-01

»View Product Info
Download Help (Windows Only)

Object reference properties can contain references to LabVIEW, .NET, ActiveX/COM, and other objects. When a property is an object reference, you can use the Release Object button, which displays only when the value of the property is non-zero, in the Value column on the Variables pane to release the reference.

You can set the reference value by using an expression, using the TestStand API, or configuring a call to a code module with a parameter or return value that returns such an object.

When you have two object reference properties and use the equality operator in an expression, TestStand performs an equality comparison on the IUnknown pointers for ActiveX objects and the pointer values for .NET objects.

Releasing References to Objects

When you assign an object reference value to an object reference property, TestStand maintains a reference to the object for as long as the property exists, or until the value changes. TestStand automatically releases the reference to the object when the property loses scope. For example, when a sequence local variable contains a reference to an object, TestStand releases the reference when the call to the sequence completes.

You can also release the reference to the object by assigning the property a new value or the constant Nothing. Assign the constant Nothing, rather than the value 0, to clear the reference. When you assign 0 to an object reference variable, TestStand creates a numeric variable with a value of 0 and assigns a reference to that numeric variable to the object reference variable.

When you release all references to an object, the availability of the object after release changes depending on the type of object, as shown in the following table.

Type of Object Object Availability
.NET The object is available for .NET garbage collection.
ActiveX/COM The object is destroyed.

Sharing .NET Objects Between LabVIEW and TestStand

You can share .NET objects that derive from MarshalByRefObject or that are serializable between LabVIEW and TestStand. You can pass .NET references created in LabVIEW to TestStand and store the references in Object Reference variables in TestStand. You can then use those references with the TestStand .NET Adapter. Similarly, LabVIEW can directly use references you create with the TestStand .NET Adapter. Refer to Microsoft MSDN documentation for more information about MarshalByRefObject and serializable objects. These features are enabled only when you use LabVIEW 2014 in conjunction with TestStand 2014.


Not Helpful