LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

.NET invoke does not find a dependent .DLL

Solved!
Go to solution
Highlighted

I have this strange error:

- I built a C# .dll 

- Tried it out works flawless in the console, everything OK

Now i want to transistion that to LabView:

- Create my VI, set everything up as usual. .NET palette constructor, invoke node etc. Then fire it up:

- I get an error that it didnt find a dependent DLL, see screen:Capture.PNG

 

So i check the folder where i have everything for the VI .NET implementation and the DLL files are there, and its even the new Version 12 (!) and not the old Version 6.

Capture3.PNG

 

So i try to reproduce what happened in Visual Studio:

- I try again with the console: dll works still flawless and doesnt complain, can apparently also find the Newtonsoft dll and its no problem for the console app that its version 12.

- So i try something out...i delete the Newtonsoft dll's and then run the console again. And:  It gives me the exact same error i have with labview but for Visual Studio. Smiley Frustrated

Capture2.PNG

 

So....um....my interpretation: Apparently LabView cannot find my .DLL, yet its right there in the folder where i have all the other related dll's . 

How can i fix this ? 

0 Kudos
Message 1 of 4
(150 Views)
Solution
Accepted by topic author Philipp_Elhaus

That’s because of how the .Net loader tries to locate dependencies of assemblies. It looks in the directory where your exe is located and in the GAC. That’s pretty much it. 

LabVIEW has absolutely no business in loading dll assemblies and even less in trying to find any dependencies of them!

And .Net does not know about VIs and neither will it ever look in the directory in which the referencing assembly dll is located. That may feel like a deficiency but is in fact a security feature, otherwise it would be even easier to inject malicious dlls into a program.

In your console application you copy everything into the build folder so the assebly loader can find the extra dlls in the executable directory. In LabVIEW that folder is however where LabVIEW. exe is located.

LabVIEW does help this a bit by registering the directory where your project is loaded to the .Net AppDomain so you can put your dlls there if you use a project. But there isn’t really much more it can do.

Rolf Kalbermatter
Averna BV
LabVIEW ArchitectLabVIEW ChampionLabVIEW Instructor
0 Kudos
Message 2 of 4
(122 Views)

ok....i've put this into a "labview project".. now i got a new error - what is this supposed to mean?

i was thinking i have downwards compatibility e.g. i can run a 6.0 requirement with a 12.0 dll - at least that's how it works in Visual Studio. 

Is there anything i can do to force compatibility?

Capture.PNG

0 Kudos
Message 3 of 4
(109 Views)

got it to work with by using an older DLL version (6.0.1) from Newtonsoft.

0 Kudos
Message 4 of 4
(93 Views)