Example Code

Reusing .NET Interop Assembly with LVOOP in LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

    Operating System

  • Windows

    Programming Language

  • LabVIEW G

Code and Documents

Third-Party Code Repository

Some users manage their code in repositories outside of ni.com. Use your best judgment when following links to third-party sites. https://github.com/etfovac/client

Description

This is the first draft that shows the basic usage of OOP and code distribution.

 

It uses a simple TCP client wrapped/packed in a base class and derived classes and libraries, and later built into a .NET Interop Assembly for distribution and/or reuse in a different project. 

 

Of course, it needs a server to establish the TCP connection, but the idea is not to test TCP but OOP and DLL reuse, so the server will get its own repository and example.

 

.NET Interop Assembly built in LabVIEW has issues if it contains classes (not necessarily with inheritance hierarchy).
In such cases the default constructor node launches a browser window and searches for a class file on disk.
To avoid this obvious bug, use the other constructor node with pointers (init them as constants).

 

   

 

 

 

 

Project overview: (it will change in further development)

 

Simple tests that demonstrate using the classes directly in LabVIEW:

 

Testing the right constructor for .NET DLL:

 

  

 

 

 

 

 

Check the latest code at GitHub repository  as I intend to add more tests and configure more builds (DLL, Source Distribution, Installer..) and in the process share the issues and solutions I find.

 

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors