LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

.NET constructor: error loading DLL in LabVIEW exe

Hi all,

 

I'm having trouble deploying executable on various machines. My program refers to a .NET assembly (bioPDF, a great PDF tool) through a .NET constructor. On the deployment machine the resulting executable produces an error on load, complaining that it cannot find the .NET DLL, although it is located at the very same (absolute) path on dev & deploy machines.

 

On my dev machine, I have:

 

- XP Pro 32 bit SP3

- .NET Frameworks 2.0.50727, 3.0.4506.2152, 3.5.30729

- bioPDF assemblies 1.0.0.4 and 4.0.0.0 (dll version 4.0.149.7), both properly registered in <GAC>

 

I had a VI with constructor refering to assembly 1.0.0.4 in LabVIEW 8.6.1, and recompiled it on LabVIEW 2009 SP1 while redirecting to the latest assembly 4.0.0.0 (taking benefit of a bioPDF upgrade that happened in between). This works fine (both from LabVIEW 2009 and as an exe) on my dev machine.

 

Then I install the exe on another machine, that has:

 

- Win 7 Ultimate 64 bit (but I also tried on 32 bit, same issue so not related to bitness I think)

- .NET Frameworks 2.0.50727 (same), 3.0.30729 (different), 3.5.30729 (same)

- bioPDF assembly 4.0.0.0 (dll version 4.0.149.7), properly registered in <GAC> with same token and culture (=neutral) as on my dev machine.

 

When loading the exe, I get a message saying that the bioPDF DLL could not be found. I have checked that it is however present, and at the correct path (and anyway I expect the GAC registration to allow finding it anyway, should it be at a different path, right ?). If I manually navigate to the correct path to locate it, the exe runs fine, otherwise it is not executable.

 

If I install LabVIEW 2009 SP1 on the dev machine and open the VI, it warns me to have changed the loaded .NET assembly from 1.0.0.4 to  4.0.0.0, athough I DID save the VI after selecting the 4.0.0.0 version on my dev machine...

 

Could this problem be related to the following post:

Massive .NET versioning issue in LV 8.6 ?

 

(different LV version and behavior so I decided to post separately even if same potential cause...)

 

Although this was reported before LV 2009 release, I could not see this .NET versioning issue (if proven) mentionned in the "LV 2009 SP1 known issues" list. NI, shouldn't it be added to avoid wasting time troubleshooting known issues ?

 

Or do I miss some other reason for this DLL load error ?

 

Regards,

 

Vincent

 

0 Kudos
Message 1 of 10
(7,624 Views)

Hi Vince,

 

just place the mouse pointer over a .NET constructor node in LV9.0f2 and find the version info of any type you reference denoted as "0.0.0.0", no matter which DLL/version you've actually chosen. Any questions? .NET and LabVIEW is not what one would call a true love story.

 

Have you tried to remove the 1.0 version of the PDF tool on your dev machine an recompile the app? As far as I can see, LV will always reference the first DLL it finds and having only one version to deal with (4.0 in your case) could help. Just an idea...

 

Cheers, Hans

0 Kudos
Message 2 of 10
(7,609 Views)

Just a small update here for people that might run into similar issues:

 

Indeed LabVIEW doesn't always behave correctly when you ask it to select a specific assembly version in GAC (Global Assembly Cache) as soon as different versions with identical dll name do exist side by side in the GAC...

 

The only new feature to help sorting this out in LabVIEW 2011 is the ".NET Assemblies in Memory" browser (in View Menu) that lets you see loaded assemblies with version number and dll name...

 

Note that a solution that avoids the use of (misbehaving) constructors has also been suggested in another thread, that is definitely worth reading on this topic :

http://forums.ni.com/t5/LabVIEW/Massive-NET-versioning-issue-in-LV-8-6/m-p/854540#M387423

 

Vincent

Message 3 of 10
(7,092 Views)

Hello,

 

I'm facing a similar problem, I already tried several things but I'm not being able to load the DLL on my executable.

 

So, in the development (LV14) I had this same problem, but then I placed the config file like this on the Labview root folder and it worked:

 

<?xml version ="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0.30319"/>
</startup>
</configuration>

 

The problem is when I do a executable of my project, I also place the same file in the directory of the executable, with the executablename.exe.config but it doesn't work. I get the error 4 on the constructor node. The dll is a 3rd party development so I can't do anything about this.

 

I already saw when I'm in my project that it loads the assembly with the CLR V4.0.30319, and if I don't have the config file on Labview root folder It doesn't load the assembly, so I assume that is what is happenning in my executable. DO you have any idea what can I try more?

 

Thanks in advance for your time 😉

 

 

 

0 Kudos
Message 4 of 10
(4,238 Views)

In fact, if I use the config file like above it doesn't work even on development environment. It only works with this configuration file:

 

 

<?xml version ="1.0"?>
<configuration>
<runtime>
<loadFromRemoteSources enabled="true" />
</runtime>
</configuration>

0 Kudos
Message 5 of 10
(4,210 Views)

@Nrick:

 

Are you also still using LV2009? Or LV2011?

 

Everything before and including 2011 is much more difficult with .NET.

Never mind 2014 as mentioned.

0 Kudos
Message 6 of 10
(4,199 Views)

Hello Dear ,

 

Yes, as mentioned I'm using LV2014, I also have 2013 installed (I didn't try on that version), but I already tried to make a executable on LV2015 and I've got the same result. 😕

 

 

0 Kudos
Message 7 of 10
(4,195 Views)
0 Kudos
Message 8 of 10
(4,194 Views)

I've also tried that one too and nothing happenned.

 

I also am not sure about what I should configure on this part of the file:

 

        <assemblyIdentity name="AssemblyNameWithoutExtension"
                          publicKeyToken="b03f5f7f11d50a3a"
                          culture="neutral" />
        <bindingRedirect oldVersion="1.0.0.0-1.5.0.0"
                         newVersion="2.0.0.0"/>
      </dependentAssembly>

When I'm using the development mode I can see the version of the .Net assembly and that the configuration file is loading the assembly to v4.0.30319, if I don't put the config file, it doens't even load the assembly.

 

Net Assembly.png

 

0 Kudos
Message 9 of 10
(4,192 Views)

@Nrick wrote:

Hello Dear ,

 

Yes, as mentioned I'm using LV2014, I also have 2013 installed (I didn't try on that version), but I already tried to make a executable on LV2015 and I've got the same result. 😕


Anything past LV2011 is probably the same. In LV2011 or earlier .NET is a problem.

0 Kudos
Message 10 of 10
(4,176 Views)