1

I was trying to run NUnit with framework 4.5 (I have VS2010 and VS2012 installed on my machine).

So I tried the old approach by editing the .exe.config file for nunit

I noted the framework version as 4.5.50709. However this failed at runtime; saying that the specified version isn't available and prompt to download and install.

Quick internet check states the registry is the place to look HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP

No 4.5 fwk folder. Strange - so I repaired the framework 4.5 installation. Still the same. Finally I delve into the 4.0 key I find

InstallPath = %WINDOWS%\Microsoft.Net\Framework64\v4.0.30319
TargetVersion = 4.0.0
Version = 4.5.50709

Hmmm looks like 4.5 has overridden 4.0. So I modified the .exe.config

<supportedRuntime version="v4.0.30319" />

This worked. Nunit now reports that it is running on v4.5

  • Why does 4.5 install in this manner ?
  • It seems to be 'redirect'ing - Is this because 4.5 is an in-place update ? If yes, why doesn't specifying 4.5.50709 not work ?
Community
  • 1
  • 1
Gishu
  • 134,492
  • 47
  • 225
  • 308
  • 1
    See if See [Compatibility of .NET Framework 4.5](http://blogs.msdn.com/b/dotnet/archive/2011/09/26/compatibility-of-net-framework-4-5.aspx) helps. – Alexei Levenkov Jan 15 '13 at 17:09

1 Answers1

4

Just like .NET 3.0 and 3.5, .NET 4.5 is an in-place update. In other words, it replaced the original 4.0 install. The CLR version number is still 4.0 and so are all of base assemblies.

So you do have to select 4.0 in the app.exe.config file. You can make it more specific and refuse to run the test when 4.5 is not present by using the sku attribute, but there's little point to it, the test should fail anyway.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • Maybe you knew this all along, but there is a difference in the configuration of supported runtime (for fwk v4.0 and up), you no longer are required to quote the entire version number 4.0.30319 just 4.0 is what is recommended (and that should reroute it to whatever is installed (4.0 or 4.5). http://msdn.microsoft.com/en-sg/library/w4atty68.aspx - That was my missing piece of this jigsaw – Gishu Jan 16 '13 at 06:05
  • Correct me if I'm wrong, but .net 3 and 3.5 are not in place updates (check folders in C:\Windows\Microsoft.NET\Framework) - it does not update files in v2.0.50727 folder. .net 4.5 is actually the first in place update - updating files in v4.0.30319 folder. I'm still trying to figure out why they did that... It brings loads of potential compatibility problems which nobody has time to fix. Imagine a pc with .net 4 installation and all .net 4 apps working. Now when .net 4.5 is installed because of one app, the rest of the apps might potentially have an issue. – xhafan Feb 19 '15 at 16:18
  • Well, you are wrong. Most visible from the [MSDN article](https://msdn.microsoft.com/en-us/library/cc189907%28v=vs.90%29.aspx) for WaitHandle.WaitOne(int) overload, added in 3.5. They called it .NET 2.0 SP2, caused quite a bit of misery. – Hans Passant Feb 19 '15 at 16:45