NUnit V2.1 in Visual Studio 2005 Beta 1

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.

Comments (20)

  1. Roo says:

    That was the last little tip I needed to get started with .NET Framework v2.0 development.

    Thank you so much…

  2. Joe says:


    Now we can carry on testing VS 2005. No way my team would do that without NUnit.

  3. Craig says:

    You should be able to put that requiredRuntime version="v2.0.40607" at the top of the list and leave the rest in there, rather than removing all of the other entries. That will allow you to run whether or not the Whidbey beta is installed.

  4. Craig,

    Actually, I found that I did indeed have to remove the other elements in the startup list and leave only the required 2.0 for it to load my assembly properly. Otherwise, it would throw a BadImageFormatException. This is on a machine with both 1.1 and 2.0 installed.

  5. James Newkirk says:

    I have to remove them all but the 2.0.40607 reference as well. I will continue to explore.

  6. Joshua Davis says:

    Thanks James now I don’t have to reinstall the May Preview Version to do unit testing.

  7. ALan Zhang says:

    Visual Studio2005下配置及运行NUnit~~不会没听说过NUnit吧?

  8. it360 says:


  9. csdnexpert says: