Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
Debugger Roadmap
Exception Assistant
 Troubleshooting Exceptions: System....

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
Visual Studio Debugger
Troubleshooting Exceptions: System.BadImageFormatException

A BadImageFormatException exception is thrown when the file image of a DLL or executable program is not valid.

Make sure the file image is a valid managed assembly or module.

This exception is thrown when unmanaged code is passed to Load for loading.

For more information, Visual Basic users can see Troubleshooting Interoperability (Visual Basic).

Make sure you have supplied a correct file path for the assembly.

If using a relative path, verify that the current directory is correct.

Reflecting on C++ executable files may throw this exception. This is most likely caused by the C++ compiler stripping the relocation addresses or the .Reloc section from the executable file. To preserve the .relocation address in a C++ executable file, specify /fixed:no when linking.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
32-bit DLLs on a 64-bit OS      chaiguy1337   |   Edit   |   Show History
This exception can occur when a .NET application running on a 64-bit platform attempts to load a DLL that does not support native 64-bit execution. If the application is built in platform-agnostic (i.e. "Any CPU") mode, it will launch in 64-bit mode on the host operating system, leading to this problem. To fix this, you can force the application to run in 32-bit mode by compiling for x86 architecture explicitly, forcing the program to launch in WoW64 mode on the 64-bit system, and allowing the 32-bit DLL to be accessed.
Tags What's this?: Add a tag
Flag as ContentBug
Solved my COM creation error 80040154      Jcrowusa   |   Edit   |   Show History

Had a problem when executing a dll and searched high and low on why it was erroring. I knew it wasn't a missing supporting DLL because the same DLL executed fine from a VB6 application. Recompiled the application targeting x86 and everything works great!

Thanks for the heads up Logan1337. Makes sense after thinking about it, but just assumed if ran ok under x64 that dlls would be fine. Not so! I also see why its taking so long for 64 bit apps to come out if you have to recompile every DLL to x64 as well.

Tags What's this?: Add a tag
Flag as ContentBug
Actually moving a project from x64 to x32 cause me this excpetion      Daniel-   |   Edit   |   Show History

I can't make the WCF host to treat my 32 compiled server.... still looking for a solution.. when will we have Edit and Continue in x64 ?

Tags What's this?: Add a tag
Flag as ContentBug
Dll built with x86 caused this exception      CristianGhe   |   Edit   |   Show History
I got this exception when an executable (manged code) built with Any CPU tried to load a dll build with x86 on Vista 64. I had to rebuild that dll with Any CPU and this fixed it.

See more info here: http://www.hanselman.com/blog/BackToBasics32bitAnd64bitConfusionAroundX86AndX64AndTheNETFrameworkAndCLR.aspx


Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker