Andrew Maddison


NUnit System.BadImageFormatException

I Recently got sent a .net project which loaded and compiled fine (and even ran fine), but when running the tests it threw the following exception:

SetUp : System.BadImageFormatException : Could not load file or assembly 'SomeProject, Version=, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.

I found a solution here: The summary is - check the properties on all your projects (test and system under test) and make sure the Platform Target ia set to “any cpu”. In the linked blog is was the Tests that had been set to x86, in my case it was the system under test.