Introduction

Even if you have .NET framework 4.0 (or above) installed correctly, Visual Studio sometimes does not pick it up. This means that you will be unable to convert any of your projects to compile against 4.0 (by setting the ‘build target’ to 4.0 or above). Simply changing the ‘target platform’ setting in the web.config to 4.0 does not do anything. You actually need to go through Visual Studio’s –>Project Level –> Properties –> Build –> Target Framework (or Application—>TargetFramework) – and set it to the framework of choice. In my case, I DID NOT see 4.0 or 4.5 (in spite of having both of these frameworks installed on my machine).

MISSING Framework 4.0 and 4.5

build_target_dotnet_framework 

First thing I learned was that Visual studio uses the following path to CHECK for these installed frameworks (it is the folder for referenced assemblies – referenced by VS, I am guessing):

C:\Program Files\Reference Assemblies\Microsoft\Framework\xxx

For each installed framework, there is a folder (v3.0, v3.5) as shown below containing the assemblies that VS needs for its tasks.

 

dotnet_framework_4.0_reference_assemblies

As you can see, v4.0 is missing. I had this issue on my computer – and re-installing the 4.0 framework did not address it.

This folder is needed only by Visual Studio, so I thought maybe reinstalling Visual Studio will do the trick.  That did not work either.

When this folder goes missing, it seems impossible to bring it back by doing a re-install.

TWO Solutions

Solution 1 (Recommended)

Try downloading and installing Visual studio 2013 (from here). That will install all the required .NET frameworks correctly – in places where Visual Studio needs to look for them.

Solution 2 (may work)

Another solution that worked for me was to copy this folder (v4.0 folder from another machine that had the v4.0 folder) – into the Framework folder above. This seemed to make Visual Studio happy and I could now pick v4.0 for my ‘target framework’ for my VS projects.

Summary

Visual Studio’s inability to pick up the correct .NET framework seems to be an annoyance – and re-installing BOTH Visual Studio and the framework does not seem to help. What worked for me was installing the latest version of Visual Studio (2013). You can also try the folder copying trick for a time saving solution. Once I installed VS 2013, I was able to see the correct framework versions in my ‘build target’ dropdown.

application_target_dotnet_framework

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.