I recently installed Visual Studio 2005 Beta 1 and wanted to understand what I had to do to get NUnit running. NUnit installed without a problem. Cool, instinctively I did what I do every time I install NUnit, I run NUnit’s tests. All 478 NUnit tests pass.
I then decided to build a class library that targets the new version of the framework. I included the reference to the nunit.framework.dll and then compiled. The program compiled but when I ran the tests in NUnit I got the following exception:
System.BadImageFormatException : The format of the file ‘TestLibrary’ is invalid.
I went to the config file (nunit-gui.exe.config) in “C:\Program Files\NUnit V2.1\bin” directory and looked for the <startup> section. I knew to do this because I was responsible for NUnit when V1.1 of the framework was in Beta and had run into similar issues. When I opened the file the <startup> section looked like this:
<requiredRuntime version=“v1.0.3705“ />
<supportedRuntime version=“v1.1.4322“ />
<supportedRuntime version=“v1.0.3705“ />
I added the following line for the new version of the framework thinking that would fix the problem:
<supportedRuntime version=“v2.0.40607“ />
I then reran NUnit. I still have the same error. After experimenting with different choices the only one that works is the following:
<requiredRuntime version=“v2.0.40607“ />
Once I changed the .config file to this the tests in my test library ran as well as NUnit’s tests. One thing to remember is that you also have to change the nunit-console.exe.config file in the same fashion.