Overview
These example shows how to access a struct datatype that has been created on .NET C# within LabVIEW.
Steps to Implement or Execute Code:
- Open New project on Visual Studio
- Choose Visual c#>>Class Library
- Drop in this example code:
namespace clusterPassing
{
public struct myStruct //Here you define a structure within "ClusterParsing"
{
public string myStr;
public int myInt;
}
public class myClass //Here a class is created within "ClusterParsing"
{
public int myMethod(myStruct data1) //Here a method for this class is defined
{
return data1.myInt;
}
}
}
- Select Build>>Solution (This will build a .NET assembly with the dll)
- Open LabVIEW and drop a .NET constructor Node in the block diagram
- Double click on the Constructor Node and it will bring a list of all the registered dlls on your machine. This registry is called the GAC(Global Assembly Cash).
- Select the desired dll from the GAC. If you do not have a Microsoft certified dll you will have to browse to find it. This will happen if the dll was created by you.
- Now use Invoke Nodes to access Actions or Methods and Property nodes to access properties and variables from the classes found on this dll.
Additional Notes:
The LabVIEW example attached is not ready to be run, it is just meant to show how to access properties and methods of the class included on the respective dll.
**This document has been updated to meet the current required format for the NI Code Exchange.**