How Do I Use a LabVIEW-Built Shared Library in a .NET Project?

Updated Aug 25, 2023

Reported In

Software

  • LabVIEW Professional
  • LabVIEW Base
  • LabVIEW Full
  • LabVIEW Application Builder Module

Other

Microsoft Visual Studio

Issue Details

I created a shared library (DLL) using LabVIEW and would like to call functions from the DLL from a .NET project using Microsoft Visual Studio.

Solution

Managed code (.NET) can easily call functions contained in unmanaged DLLs, such as Win32 API and custom DLLs. To do this, the .NET Framework provides a mechanism called P/Invoke (for Platform Invoke). Refer to the related links section for examples and further information.

If you have the source code of the LabVIEW project, it is possible to create a .NET interop assembly by right-clicking Build Specifications >> New >> .NET Interop Assembly. This will generate a .NET DLL that can be called from a .NET application.