Sunday, August 23, 2009

NUnit on 64 bit

I have a Windows 7 x64 version on my computer. I’m developing a project that uses Sql CE 3.5. While SqlCE depends on x86 binaries, I had to set my .NET project settings to compile code to x86 architecture. I forced .NET to load the assemblies as x86 binaries.

I wrote NUnit tests for my project. When I tried to run them, I got a huge exception:

System.BadImageFormatException : Could not load file or assembly 'ASSEMBLY' or one of its dependencies. An attempt was made to load a program with an incorrect format.

NUnit.exe is an architecture-independent IL code, so it runs as an x64 code on my machine. My project is an x86 code, so NUnit couldn’t load the DLLs into it’s appdomains.

Run NUnit-x86.exe because that is a 32-bit assembly.