.Net Error – BadImageFormatException An attempt was made to load a program with an incorrect format.

When i try to upgrade one of my application at work today from VS2005 to VS2008 I have received the following error.

“BadImageFormatException was unhandled”

Could not load file or assembly ‘xxx’, Version = x.x.x.x, Culture=neutral, PublicKeyToken=null’ or one of its dependencies. An attempt was made to load a program with an incorrent format

This error is caused by one of the library, i created 1.5 years ago, which is a helper class for crystal report 11 R2 (from VS2005). I am quite worry this library if it is not going to work on any newer version of VS / .NET. Because of different version of .Net Framework!?

Fortunately, I remember that,I have some issue with 64bits windows before with SSIS and on another application that I created. It would be a good try to compile this application in 32 bit.

Here it is my solutions.

1) On Visual Studio Open “My Project” from the “Solution Explorer
2) Click on the “Compile” Tab
3) Then Click on “Advanced Compile Options…
Select “Advanced Compiler Settings” -> Update Target CPU property to “x86” instead of “Any CPU

I guess this error occurs is because the library that i created/Compiled is on a 32 bits windows. Now i am using a 64 bits machines. When I run the application i throw that error.

Hope you find it useful.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.