Example Code

Using .NET to Call LabVIEW DLLs That Pass String Data Types

Code and Documents

Attachment

This example demonstrates how to pass a string from .NET (C#) to a LabVIEW DLL that returns a string by reference.

The reason this is slightly different is because of how LabVIEW Strings are structured. Strings in LabVIEW not only contain the actual characters of the string, but also the length of the string. As such, the calling program must know the length of the string that is being returned.

There are two folders in the attachment:
LabVIEW Code: Contains the LabVIEW VI and Project to create the DLL
DotNet Code: Contains the .NET C# Solution and a copy of the DLL in the bin folder

Note: If you make changes to the VI and rebuild the DLL, you must copy it over to the .NET solution's output (bin) folder, i.e. the same directory as the executable.

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

Comments
Zeagler
Member
Member
on

Hi, can you link this document to other documents that relate Integrating LabVIEW-built dll's with .NET or other languages such as:

 

http://www.ni.com/tutorial/5719/en/#toc2

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019MDiSAM&l=en-US

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019Ls1SAE&l=en-US

 

Contributors