Partager via


BadImageFormatException Reproduced in Visual Studio 2008 on x64 Windows

This posting is provided "AS IS" with no warranties, and confers no rights.

Well, I guess most ASP.NET people know “Platform target” setting in a project.

image

There are four options, Any CPU, x86, x64, and Itanium (aka IA64). When you are debugging a web application inside Visual Studio 2008 on x64 Windows, sometimes you will see such an error page with BadImageFormatException,

image

Don’t panic. Go and check your project’s Properties about “Platform target”. Switch it to a recommended option and test again.

In order to save your time, I try to provide a table here for your reference,

  Any CPU x86 x64 IA64
Cassini OK OK ERROR ERROR
IIS OK ERROR OK ERROR

* by default, Cassini (aka Visual Studio Development Server) processes are 32 bit and IIS worker processes are 64 bit on x64 Windows.

clip_image001

I don’t have a IA64 box to test, so I fail to have a IA64 build working at last.

It is easy to explain the result if you read this article. Usually 64 bit processes cannot load 32 bit components, and vice versa.

Notice that it is possible to run IIS worker processes in 32 bit mode even on 64 bit Windows. Refer to this article for IIS 6 and this for IIS 7. No warranties is provided. Support is limited to this blog.