BadImageFormatException was unhandled

J

John A Grandy

VS2005 ( all updates ) on XP ( all updates )

I have a solution with many projects and a substantial reference tree.

I have a Windows Application project that will build but not run. It fails
in Program.cs when it attempts to invoke the form class :

Application.Run( new Form1() );


BadImageFormatException was unhandled

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


The strange thing is that other Windows Applications that contain a
reference to the MyApi assembly run just fine.

I clean and rebuild to no avail. Also, removing/adding ref does not help.

What could be going on ?
 
A

Atul Rane

John A Grandy said:
VS2005 ( all updates ) on XP ( all updates )

I have a solution with many projects and a substantial reference tree.

I have a Windows Application project that will build but not run. It fails
in Program.cs when it attempts to invoke the form class :

Application.Run( new Form1() );


BadImageFormatException was unhandled

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


The strange thing is that other Windows Applications that contain a
reference to the MyApi assembly run just fine.

I clean and rebuild to no avail. Also, removing/adding ref does not help.

What could be going on ?


Hi john,
I think the problem is in your image which is you trying to open, try to
open different image file.
 
J

John A Grandy

No this has nothing to do with image ( .img ) files. I am not working with
any images.
 
J

jacky kwok

John said:
No this has nothing to do with image ( .img ) files. I am not working with
any images.


In general, this exception happens when a dependent is not correct in
the current OS platform.

For example, in 64 bit OS, a dotnet2 app loads a native 32bit DLL. (64
bit app cannot load 32 bit DLL).

Since, no info about what is the platform the problem happens, cannot
confirm is this case.

Note about that, for dotnet2 app, the will run as 64 bit app in 64 bit
OS, except the developer directly mark it is 32bit only. Otherwise, the
64 bit main exe cannot load any 32bit DLL, include the DLL which uses
managed C++ and it calls the win API, or other natvie C 32bit DLL.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top