Just had a very strange run-in with Visual Studio 2010 throwing a BadImageFormatException. Just to set the scene I’ve got Visual Studio 2010 running on a Windows XP 64-bit machine.
My solution has a Console Application and a few Class Libraries; one of which is for Integration Tests using StoryQ and another which is for my unit tests classes.
Running my Console application works fine on its own, but as soon as I either ran the Unit Tests or got Resharper to run my Integration Tests, I was hitting a BadImageFormatException. It could not load my console application (or one of its dependencies).
A bit of blog searching found an forum thread which talks about how a new c# console application targets x86 by default. I think the combination of it attempting to run my console application in x86 and my test libraries on the 64-bit environment was causing a battle of wills.
The solution is to go into your console application Properties and switch to the Build tab. Then make sure that for both Debug and Release configurations that your Platform Target is set to “Any CPU” rather than “x86”.
This then allows your TDD to continue unchallenged by assumed defaults and the use of a 64-bit OS.