Now that multiple versions of the .NET framework are available it's sometimes necessary to force an application to run under a different framework than it was built for. This is especially necessary when the application is loading assemblies at runtime.
NUnit is a great example of this. The downloadable binary version of NUnit was built for the 1.0 framework, but your application and unit tests may have been built under the 1.1 framework and, even worse, may be making use of 1.1-only features. If the have both the 1.0 and 1.1 frameworks installed, NUnit will start up using the 1.0 CLR and framework classes since that's what it was built for. Then when you try to run your tests they will be running (or crashing..) on the 1.0 framework even if they were built for 1.1! This happens because there can only be one version of the framework per process and since NUnit started using the 1.0 version, your tests have to use that version too.
If your application is built for 1.1 then it doesn't make sense to run all your unit tests on 1.0. If you're making use of 1.1-only features, then you have no choice but to test it on 1.1. The key is to force NUnit to run under the 1.1 framework by adding the following <supportedRuntime> option to the nunit-gui.exe.config file in NUnit's directory.
<?xml version ="1.0"?> <configuration> <startup> <supportedRuntime version="v1.1.4322" /> </startup> </configuration>Where the version is the exact version of the framework you want to force NUnit to run under.
I've found this to be a much cleaner solution than rebuilding NUnit and referencing that custom build of nunit-framework.dll from all my unit tests. For more information about targetting a specific version of the .NET framework take a look at this article on MSDN.
Posted by JoshC at July 10, 2003 10:24 AMhttp://www.joshchristie.com/weblog/mt/mt-tb.cgi/7
Listed below are links to weblogs that reference 'Run NUnit on the right framework' from Josh Christie's Weblog.
