Click here to Skip to main content
15,881,588 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Visual Studio 2010
DotNet framework: v3.5
Operating system: Win7

Program compiled successfully but exception on run.

Bad Image Format Exception

Could not load file or assembly 'Interop.SQLDMO, Version=8.5.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Any one please help. how to resolve it.
Posted
Updated 25-Nov-13 22:39pm
v2

Difficult to tell from just that, but it is quite likely that you are running a 64bit application and trying to load a 32bit library.

Try changing your project settings to "x86" instead of "x64" and try again.
 
Share this answer
 
Comments
DoingWork 26-Nov-13 5:01am    
Yes I'm using 64-bit machine but this project was developed in 32-bit machine.
After changing project setting from "Any CPU" to "x86", this error occurred on compilation.

An assembly with the same simple name 'Interop.SQLDMO, Version=8.5.0.0, Culture=neutral, PublicKeyToken=null has already been imported. Try removing one of the references or sign them to enable side-by-side. G:\WorkDrive\..........\obj\Release\Interop.SQLDMO.dll
OriginalGriff 26-Nov-13 5:12am    
That's the problem then: "AnyCPU" on a 64 bit machine expects 64 bit assemblies.
Ass I said for your "spare" question - remove the reference(s) and add them back again.
DoingWork 26-Nov-13 5:23am    
Thanks problem resolved.
Will this application run on both "x64" and "x86" systems ????
OriginalGriff 26-Nov-13 5:41am    
If you set it to "x86" it will work on both 32 and 64 bit systems, yes.
DoingWork 26-Nov-13 6:02am    
ok Thanks
Hi,

I think its a architecture related problem.

Which architecture you use :32 bit (x86) or 64 bit (x64)

which ever you use please try the same version of dll and client should also use the same version of architecture.

Thanks
Suvabrata
 
Share this answer
 
v2
Comments
DoingWork 26-Nov-13 5:03am    
I'm using 64-bit machine but this project was developed in 32-bit machine. Now with project setting "x86", this error occurred on compilation.

An assembly with the same simple name 'Interop.SQLDMO, Version=8.5.0.0, Culture=neutral, PublicKeyToken=null has already been imported. Try removing one of the references or sign them to enable side-by-side. G:\WorkDrive\..........\obj\Release\Interop.SQLDMO.dll
Suvabrata Roy 26-Nov-13 5:17am    
Remove the reference and pick reference from your GAC and I think it will run fine...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900