Troubleshooting Exceptions: System.BadImageFormatException
Updated: April 2011
A BadImageFormatException exception is thrown when the file image of a DLL or executable program is not a valid managed executable.
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.
For more causes of this exception, see the BadImageFormatException class.