10 December 2012 CI Team Edit

 

It seems to be an easy question but there are also some traps. The reason is that theoretically it is possible to make a difference between CLR Version and Framework Version. In the times of .NET 3.5 it was usual to keep the CLR version still on version 2.0 because there are only new libraries added to the framework.

But “.NET Framework 4.5” usually means the combination of the “newest” frameworks and CLR Version. Although .NET 4.5 is an “in-place-upgrade” for .NET 4.0 what makes the whole situation even more complicated.

Good entrance (and I’m going to talk about this later again) is the post of Scott Hanselman:

.NET Versioning and Multi-Targeting - .NET 4.5 is an in-place upgrade to .NET 4.0

Easy check for: Is the .NET Framework Version 4.5 installed or not?

To clarify what version you’ve got installed you will find an helpful hint from the registry at the pad “Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full”

image

In my cases it is: Jepp - .NET 4.5. Unfortunately this test will only work if you are the system-admin and in full control of the system and the applications.

Does my application run with .NET 4.5?

This doesn’t mean if the application is “compatible” to .NET 4.5 but if the application is able to use the .NET 4.5 features.

It’s kind of difficult to answer this question since this depends on the app.config or the web.config and if the IIS is in the game you have to configure the AppPool properly.

If you read the Hanselman Post you are now going to get a very short version of it Zwinkerndes Smiley

If you run a Desktop Application without the correct framework version in the supportedRuntime Element of the app.config you are going to receive an error message. That’s how I tell my Runtime that my app needs .NET 4.5: <div id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:22338c3f-edfb-4ca9-b694-8f81b5044338" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;"> <pre class="c#"><?xml version=”1.0” encoding=”utf-8” ?> <configuration> <startup> <supportedRuntime version=”v4.0” sku=”.NETFramework,Version=v4.5” /> </startup> </configuration></pre> </div> When there is no .NET 4.5 that’s your error message:

image1662

There is a similar element for Web-Application in the web.config:

If the Runtime the TargetFramework needs isn’t there you will see another error message if you try to run the Webapp.

Bets Practice: Feature Detection during the runtime

<div id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:4dd8ea3e-3204-4b7f-9fc6-953b2c07afcd" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;"> <pre class="c#"><configuration> <system.web> <compilation debug=”true” strict=”false” explicit=”true” targetFramework=”4.5” /> </system.web> </configuration></pre> </div>

Since the framework always includes several libraries and every library has a different version number and a different Runtime you might test properly if there is something like a special class for example.


blog comments powered by Disqus