Showing results for 
Search instead for 
Did you mean: 

Calling LabView Shared Library DLL from Visual Studio

Go to solution

Hello Community,


I am using LabView 2022 and Visual Studio 2022.


In LabView I created a project with a vi that has a single input and output. Then I created a shared library (DLL) and added the vi as the source file using "C Calling Conventions". (Please see attachment)


In Visual Studio I created a Windows Forms App (.Net Framework) with .NET Framework 4.8. In the project "Solution Explorer" I right clicked reference to add a reference. Then I browsed for my SharedLib.dll file and get the following error below.

"A reference to SharedLib.dll could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component."


Not sure if I am doing this correctly, but I tried using the following executable in the command prompt. This method was suggested in some forms during my search.

C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\TlbImp.exe SharedLib.dll

 I receive the following errors below during my attempts.

TlbImp : error TI1001 : Unable to locate input type library: C:\...\SharedLib.dll
TlbImp : error TI1002 : The input file 'C:\...\SharedLib.dll' is not a valid type library.


Is this the proper way to create a LabView dll? If so, how do I add the reference in my Visual Studio project to be used?


Any help is greatly appreciated. Thank you!

0 Kudos
Message 1 of 6

If you want to access the LabVIEW library from a .Net application you better would create a .Net assembly from it. A shared library is an old style shared library that would need to be imported into .Net with an Interop interface. Not impossible, but since you want to use .Net anyhow you can make your life a lot easier by creating the assembly instaed. .Net Interop code is not for the faint hearted.


Notice that even if you create a .Net assembly in LabVIEW, it is NOT an architecture independent MSIL assembly. It is in fact a mixed mode assembly with the actual LabVIEW code being compiled as x86 or x64 compiled machine code and a .Net proxy wrapper around it that lets you call it like a .Net assembly. So you must use the same bitness in LabVIEW to create the assembly as you want to use for the .Net application (most likely x64).

Rolf Kalbermatter
My Blog
Message 2 of 6
Accepted by topic author MechUnit

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

I have used a LabVIEW .NET Interop Assembly in a .NET application. Feel free to ask any questions

Message 3 of 6

I created and built the .NET Interop Assembly, InteropAssembly.dll, in my LabView project. I was able to add the InteropAssembly.dll and NationalInstruments.LabVIEW.Interop.dll to my Visual Studio references. When I run my program, I get the following error below. Please see attachment "ProgramError.png".


System.BadImageFormatException: 'Could not load file or assembly 'InteropAssembly, Version=, Culture=neutral, PublicKeyToken=null' or one of its dependencies. 
An attempt was made to load a program with an incorrect format.'


Visual Studio 2022 and LabView 2022 Q3 are 64-Bit. I would like to use Net Framework 4.8. I found an article that said LabView 2022 Q3 requires NET Framework 4.6.2 for install, but where can I check to see what version is currently being used? Any other ideas on this error?

Download All
0 Kudos
Message 4 of 6

It worked when I set the visual studio application to have the target framework ".NET Framework 4.7.2".


Is there a way to have LabView use ".Net Framework 4.8?

0 Kudos
Message 5 of 6

It seems to be working now with ".Net Framework 4.8". Thank you for your help!

0 Kudos
Message 6 of 6