Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bad Image Format exception problem [duplicate]

Possible Duplicate:
BadImageFormatException during .Net assembly load issue

I am trying to run a exe file which loads a assembly and extracts its version. The file is working fine on win xp but while running it on win 7 it crashes giving the following exception.

Unhandled Exception: System.BadImageFormatException: Could not load file or asse
mbly 'some.dll' or one of its dependencies. An attempt was made to load a program with
 an incorrect format.
File name: 'some.dll'
   at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase,
Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boo
lean throwOnFileNotFound, Boolean forIntrospection)
   at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence
 assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at NxTools.InstallTools.Utils.MIPSettings.MIPEnvironmentSettings.Main(String[
] args)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\M
icrosoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure lo
gging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fus
ion!EnableLog].

Has anybody faced this problem? What could be the probable solution to this problem?

like image 919
Shashank Avatar asked Dec 03 '22 03:12

Shashank


1 Answers

This can have several causes, the most likely is that you are trying to load a 32bit managed dll on a 64 bit machine, or vice versa.

It can also mean that a dll you are dynamically loading is not a native dll, or that the dll file is corrupted.

It may mean that you have a dll which is using a higher version of the .Net framework than some other dll that is using it, if you rebuilt a particular component with a different version for example.

This question covers similar ground, as does this one which also suggests a way to force your 64bit app to run in 32bit mode so it can load the 32bit dependency.

like image 187
Sam Holder Avatar answered Apr 14 '23 17:04

Sam Holder