LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

.NET DLL System.BadImageFormatException

Solved!
Go to solution

I have builded a .NET dll which is a wrapper of the or-tools, http://code.google.com/p/or-tools/, made by google. I import these by "tools->import->.NET controls to pallet->browse" and select the various dll's. When I do this I get the error

 

pic.png

 

Translated from Dutch to English it comes to this:


"System.BadImageFormatException: Can not load file of assembly C:\or-tools\Google.OrTools.ConstraintSolver.dll or one of it dependencies. This assembly is build by a runtime newer then the currently loaded runtime, and can not be loaded. <append><b>System.BadImageFormatException</b>.

My question is why does this error actually occure? Is it mostlikely because I builded it with .NET 4.0? If so, will it help if I build it with .NET 3.5? Or does LabVIEW doesn't support that either? I hope a NI employee can give me some insight :). 

 

The dll can be downloaded at: http://code.google.com/p/or-tools/downloads/list

0 Kudos
Message 1 of 11
(15,614 Views)

I think the actual problem in your case is more likely to be 32-bit vs 64-bit. Did you download the correct one for your operating system? Or, did you compile a 64-bit version and are running 32-bit LabVIEW (or vice-versa).

0 Kudos
Message 2 of 11
(15,606 Views)

I'm running 32 bit version. I also downloaded and compiled the 32 bit version... But am I now in the understanding that you downloaded the dll and it worked for you?

0 Kudos
Message 3 of 11
(15,599 Views)

The intiali guess about .Net 4.0 is probably correct. Although 32 Bit and 64 Bit of course need to match as well on LabVIEw and DLL side, LabVIEW does not yet support .Net 4.0 out of the box. Supposedly you can write a manifest file and place it in the directory where LabVIEW.exe is to force LabVIEW to load with .Net 4.0 anyways but it is a workaround, not a proper solution. Recompiling with .Net 3.x is definitely the better solution if you have the source code of the component and that source code does not make use of .Net 4.0 features.

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 11
(15,590 Views)

Hmmm well removing all the code so that it compliles on .NET 3.5 would be a job too time expensive for me at the moment. But I'm still wondering if the DLL worked for you guys? Or it didn't as well? If the latter then I just have to wait till LabVIEW supports .NET 4.0 I guess... (which I hope is with the next release???)

0 Kudos
Message 5 of 11
(15,571 Views)

@WouterG wrote:

But I'm still wondering if the DLL worked for you guys?


It did not. At least not in LabVIEW. I was able to add it as a reference in Visual Studio 2010.

0 Kudos
Message 6 of 11
(15,568 Views)

Ya okay, in VS 2010 it also works for me... but not in LabVIEW.

0 Kudos
Message 7 of 11
(15,566 Views)

I only touch .Net if I absolutely can't avoud it. This here doesn't count as such for me. 🙂

Rolf Kalbermatter
My Blog
0 Kudos
Message 8 of 11
(15,563 Views)
Solution
Accepted by topic author WG-

Hi,

 

I think that you have your answer but for more info about the .NET 4.0 and LabVIEW you can read the links which are given below.

 

http://digital.ni.com/public.nsf/allkb/32B0BA28A72AA87D8625782600737DE9?OpenDocument

http://zone.ni.com/reference/en-XX/help/371361H-01/lvhowto/configuring_clr_version/

 

Regards,

 

Hossein

 

 

Message 9 of 11
(15,552 Views)

That worked! Awesome 🙂

0 Kudos
Message 10 of 11
(15,547 Views)