Problem with exceptional image format error

Possible duplicate:
BadImageFormat exception while loading .Net build problem

I am trying to run an exe file that loads an assembly and retrieves its version. The file works fine on win xp, but when it runs on win 7 it fails, 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 anyone encountered this problem? What is the likely solution to this problem?

+4
source share
2 answers

This may have several reasons, most likely you are trying to load a 32-bit managed dll on a 64-bit machine, or vice versa.

It may also mean that the dll you are dynamically loading is not a native dll or that the dll file is corrupt.

This may mean that you have a dll that uses a higher version of the .Net framework than any other DLL that uses it, for example, if you rebuilt a specific component with a different version.

This question covers a similar soil, like this one , which also offers a way to get your 64-bit application to run in 32-bit mode so that it can load a 32-bit dependency.

+15
source

Make sure you are using 64-bit Windows and the ist 32bit ONLY DLL (special versions for 64-bit Windows are sometimes available)

+3
source

All Articles