Today I decided it was time to set some of my projects to use .Net 4 instead of .Net 3.5 and I felt the pain.

First, I had some trouble with my barcodereader framework which was built for .Net 1.1. No problem, I quickly changed it over with another framework I like better and which is built for .Net 4.0.

Then I committed and I broke the built :-(. The test projects I had converted to .net 4.0. would not build anymore.

System.BadImageFormatException: Could not load file or assembly ‘C:Visual studio projectsTDB2009ProjectsTDB2009.View.Menu.TestCbinDebugTDB2009.View.Menu.TestC.dll’ or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

And this in the output.

Execution Runtime: net-2.0

That won’t work.

First thing I did was to upgrade NUnit to version 2.5.5 from version 2.5.2.

That didn’t help. Perhaps it did but not at first.

Searching google I found this.

Getting .Net 4.0, Team City, MSBuild and Nunit to play nice.

And what helped me was this line.

Modify nunit-console.exe.config with the following:

under <configuration> add: <startup> <requiredruntime version=“v4.0.30319”></requiredruntime></startup></configuration>

GUI config. And all is well again.