Introduction

If you have just upgraded to .NET 4.5 for asp.net web app, you may be wondering how to ensure that your application actually is running on 4.5 and not on the older 4.0. This post points out a few of the misleading places where ‘4.0’ shows up for, what is effectively 4.5 – and also provides instructions on how to upgrade your project to 4.5.

One of the puzzling things you will notice (after installing the 4.5 framework) is that the IIS Application pools drop down does not show a .NET 4.5 framework option (see screenshot below).

IIS_App_Pool_Missing_4.5

 

If you remember .NET 3.5, it was offered as a set of enhancements to .NET 3.0. Which meant that it wasn’t its own separate runtime – just a modification to the existing 3.0 runtime. 4.5 is exactly the same – it IS an enhancement – which is why you see the old .NET 4.0 runtime as the

Compilation – Converting your app to 4.5

From your project’s properties (at the project level, not at the Solution level), you will need to select the target framework to 4.5. This will do a couple of things. First, it will add the following entry to your project’s web.config.

<compilation debug="true" targetFramework="4.5"/>

Second, it will update the .NET framework assembly references to the latest 4.5 versions – as shown in the screenshot below (check the ‘System’ assembly for a fail-safe check).

4.5_reference_assembly 

If you have any external libraries (open source, 3rd party etc.), you would do well to upgrade those to their latest versions – hopefully ones that have been compiled against .NET 4.5. This is going to be the rule rather than the exception – since 4.5 introduces async await, an async programming pattern that  most library vendors are rushing to implement.

Now that you have converted and deployed your project, how do you ensure that you are indeed running on the 4.5 runtime?

Manually Configure IIS (the relevant app pool) to use 4.5

https://www.anujvarma.com/iis-app-pool-using-4-5-framework/

Runtime Validation

  1. IIS Application Pool – Remember, IIS Application pool is no help – since it just shows .NET Framework 4.0 in the list of available runtimes.
  2. Web.Config – First, you can check the targetframework in web.config (or app.config). It should be 4.5. 
  3. Assembly File Version: Checking the actual FILE version of your reference assemblies will not help much – since they will still show 4.XXX (see below). For e.g. System.dll in the .NETFramework\v4.5 has the file version 4.0.303….So, that can be slightly misleading – this is a 4.5 assembly – though the file version says 4.0.x (for the reasons outlined at the start, 4.5 is just an upgrade to 4.0 runtime).

HttpRuntime

If you are upgrading a web.app, you are not done yet (the compiling against 4.5 step was the main step – but you need one more thing after conversion). Your web app utilizes a configuration key called httpRuntime . This supports a ‘targetframework’ attribute. If you want your web app to avail of some of the newer constructs in the 4.5 request processing pipeline, you want to explicitly set this value in the httpRuntime element. The full benefits of doing so are described in this post.

<httpRuntime targetFramework="4.5" />

Summary

Upgrading from 4.0 to 4.5 provides for some serious performance gains as discussed in this post. Converting your 4.0 app to a 4.5 app is simple. However, validating whether your app is correctly running on 4.5 is a little tricky due to the appearance of the 4.0 version everywhere (IIS App Pool, File Versions on 4.5 assemblies). You also need to do a post-upgrade setup of manually adding the httpruntime targetframework to ensure that your app does utilize the capabilities of .NET 4.5.

Anuj holds professional certifications in Google Cloud, AWS as well as certifications in Docker and App Performance Tools such as New Relic. He specializes in Cloud Security, Data Encryption and Container Technologies.

Initial Consultation

Anuj Varma – who has written posts on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.