Sunday, October 23, 2011

How to fix System.BadImageFormatException in 64-bit OS?

If you try to refere a dll which has a file format which CLR does not support, you will get this exception. In 64 bit OS, this can happen due to dll is having some 32 bit parts (COM components etc.)  and it is being loaded as a 64 bit module.

To avoid that, you need to do the following:
  1. In Visual Studio, right click the project.
  2. In project properties, go to 'Build' tab
  3. In General section, select Platform target as x86 (default is 'Any CPU')
  4. Recompile the project and execute

1 comment:

  1. i did you said. still now i have the problem???
    please help me as soon as possible


    with regards,
    shankar G

    ReplyDelete