Running NUnit tests on .NET 4.0

posted by Bryan on

We've recently moved some of our tests from the .NET 3.5 framework to run against the .NET 4.0 framework. I updated the Project target framework to be 4.0 as well. However, I was getting this error: This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. After some research, it required a pretty easy fix.

I was using the console runner for NUnit, but you could apply the same fix to the NUnit gui. Find the related NUnit configuration file in your NUnit directory. For the nunit-console runner, it is the nunit-console.exe.config file located in C: > Program Files > NUnit 2.5.5 > bin > net-2.0. Edit this file.

Under the <configuration> node, put:

<startup>
  <requiredRuntime version="v4.0.20506" />
</startup>

Under the <runtime> node, put:

<loadFromRemoteSources enabled="true" />

Now, when I load the tests using NUnit, it runs like a charm! Thanks to http://www.cookcomputing.com/blog/archives/000597.html for the solution.

Leave a comment

blog comments powered by Disqus