Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Troubleshooting Exceptions: System.BadImageFormatException
Collapse the table of content
Expand the table of content

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.

Community Additions

ADD
Show:
© 2015 Microsoft