LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using a .NET assembly compiled in LV on a different PC

Solved!
Go to solution

Hi,

 

I have built a .NET assembly from labview with some very simple functions. The figure out if other developers in our company (using Visual Studio + C#) can reuse codes I wrote.

 

If I test the assembly on my PC (with LV installed) then everything works fine, but once another guy wants to use it Visual Studio displays the following error message:

System.IO.FileNotFoundException: 'Could not load file or assembly 'NationalInstruments.LabVIEW.Interop, Version=1.6.0.0, Culture=neutral, PublicKeyToken=daeb5dc76be4e32a'. The system cannot find the file specified.

 

What should we do to make is PC able to use my dll? I assume - but not sure - that installing the lv runtime engine may solve this problem but we'd like to avoid its installation as much as possible.

 

My dev PC is 64bit Win7 with 32bit labview installed, the other guy's PC is a 64bit win10.

 

Let me know your thoughts.

Thx.

0 Kudos
Message 1 of 10
(1,734 Views)
Solution
Accepted by topic author 1984

Install the according LabVIEW runtime version on the other PC! LabVIEW DLLs are not self contained but need the LabVIEW runtime in order to initialize and run the DLL. That is true for both LabVIEW standard DLLs as well as LabVIEW .Net Assembly DLLs. LabVIEW does not compile the code into platform independent MSIL code to put into the .Net assembly but simply stores the compiled LabVIEW VIs inside the DLL and adds a small loader to the DLL. This loader initializes the LabVIEW runtime, extracts the compiled LabVIEW VIs and passes them to the runtime to execute it.

 

The installed LabVIEW runtime needs to have the same version and bitness as what was used to create the DLL.

Rolf Kalbermatter
My Blog
Message 2 of 10
(1,726 Views)

Thanks a lot.

0 Kudos
Message 3 of 10
(1,724 Views)

Hello, 

 

I am facing same issue as you by trying to use a DLL generated from LabView (.NET interop assembly) from a .NET C# application after referencing the DLL generated on the C# console app of course. After seeing your answer i have installed the LabView runtime but nothing is resolved and still getting the same issue. Could you please tell me what have you done to resolve it ? Thanks a lot 

0 Kudos
Message 4 of 10
(1,292 Views)

Which LabVIEW version did you use to compile your .Net assembly? Which LabVIEW Runtime version did you install? Same bitness?

Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 10
(1,285 Views)

Hello, 

 

I have the "LabView Community Edition" version 21.0.1 (32 bite) and runtime i have installed the "ni-Labview-2021-runtime-engine_21.1_online" but i am not seeing it running on my computer. 

 

Thanks a lot

0 Kudos
Message 6 of 10
(1,268 Views)

What does "seeing it running" mean even? What do you expect to "see"? Are you sure you got the right bitness version of the runtime?

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 10
(1,238 Views)

Actually what i did in addition to the installed version is that : 

- Have created a simple LabView schema (Decrement function called "double dec (double variable)"

- Have generated an interop DLL from LabView 

- Created a C# consol app 

- Referenced the DLL on the C# project 

- and trying to use that dec function 

But it's failing because of follwoing error: 

System.BadImageFormatException: Could not load file or assembly

 And i don't understand why i need a runtime and what I expect is seing that is runtime is up or avaialble and this is only thing i have when i install the runtime: 

HDboy33_0-1656926336792.png

 

Thanks a lot for your help

 

0 Kudos
Message 8 of 10
(1,222 Views)

And i don't understand why i need a runtime


You need the runtime because LabVIEW doesn't build dlls like for example C# does. LabVIEW dlls - as far as I understand - are LabVIEW VIs with a .net interface, so you need to have the runtime if you'd like to call them on a PC which doesnt have the LabVIEW development system installed. (also I'm pretty sure that in most cases your runtime version must be the same of the labview version used for compiling the dll. Which is by all means ridiculous but this is how it works.)

 

More scientific info in the response accepted as a Solution of this topic.

0 Kudos
Message 9 of 10
(1,211 Views)

@1984 wrote:

(also I'm pretty sure that in most cases your runtime version must be the same of the labview version used for compiling the dll. Which is by all means ridiculous but this is how it works.)


Microsoft has had the same until Visual Studio 2017. If you created a DLL in a specific version you had to install the same C Runtime version. I would not call it ridiculous but simply making the work of testing all possible permutations more managable. Since around LabVIEW 2017 you can enable in the Build settings to allow the DLL to load with a later LabVIEW Runtime than it was compiled with (and obviously not the reverse as that would be truly unmanageable). However there are some features that can then not work as intended so I generally disable that option. 

Rolf Kalbermatter
My Blog
0 Kudos
Message 10 of 10
(1,203 Views)