Sharing .NET Objects Between TestStand and LabVIEW using .NET Remoting

Publish Date: Jun 10, 2009 | 4 Ratings | 5.00 out of 5 | Print | Submit your review


The following Example Program demonstrates how to share/pass a .NET Object between TestStand and its code modules VIs written in LabVIEW.

The challenge is that we cannot simply pass the reference of a typical .NET Object that we create in TestStand to a LabVIEW VI and access it from the VI.
This is because of a technology called Application Domains or AppDomains.
Objects exist in an AppDomain, and AppDomains protect the object from being manipulated from outside programs. So a .NET Object created in TestStand is part of TestStand's AppDomain, and as such, LabVIEW (being in its own AppDomain) cannot access the object.
The following is a good source of information on AppDomains:
Wikipedia: Application Domain

The solution to this problem is another technology called .NET Remoting.
.NET Remoting is an API that allows for inter-process communication. Using .NET Remoting, we can share a .NET Object across different AppDomains, processes or even computers.
The way this works is that a reference to the shared or 'Remote' Object is made available to client applications through a .NET Remoting Server which registers and hosts the actual object.
In this way, both TestStand and LabVIEW VIs can access the same Remote Object by getting a reference to it.
The following is a good source of information on .NET Remoting:
Wikipedia: .NET Remoting
MSDN: .NET Remoting Overview

Example Program:
The Example Program contains

  • .NET Interface (DNRemotingInterface): An interface for the shared object. Also contains a static function to get a reference to the Remote Object.
  • .NET Remoting Server (DNRemotingServer): The server that registers and hosts the remote object. Also contains the definition of the Remote Object's class.
  • TestStand Sequence (TestStandSequence.seq): Creates a .NET Object and shares it with LabVIEW through .NET Remoting.
  • LabVIEW VI ( Two versions of this file exists, one for LabVIEW 7.1.1 and another for LabVIEW 8.0 and higher.

In order to run the example, follow these steps:

  1. The .NET Assemblies must be registered in the GAC (Global Assembly Cache) so that TestStand and LabVIEW can find them.
    To do this, run the attached batch file: RegisterAssemblies.bat
  2. Select the right version of the LabVIEW VI:
    If you are using LabVIEW 7.1.1, rename to
    If you are using LabVIEW 8.0 or higher rename to (This is done by default)
  3. Open TestStand and load TestStandSequence.seq
  4. Run the TestStand Sequence

The TestStand Sequence will:

  1. Launch the .NET Remoting Server. This will also create the shared or 'Remote' Object
  2. Call the static function to get a reference to the Remote Object
  3. Use the reference to call a method on the Remote Object
  4. Call a LabVIEW VI that also gets a reference to the Remote Object and calls a method on it.
  5. Call a method on the Remote Object directly without the reference through Remote Call

This demonstrates both how to share an object between TestStand and LabVIEW and also two different ways of accessing this Remote Object in TestStand.


Back to Top

Bookmark & Share





Rate this document

Answered Your Question?
Yes No