visual-studiosdkvisual-studio-2017.net-framework-version

error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.5" were not found


I have recently upgraded my Visual Studio environment, and now I seem to have a problem with my .Net framework, as you can see in following error message:

9> C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(1126,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

(the number "9" is just a counter of the nineth project within my Visual Studio solution)

Let me explain you what's so confusing about this situation:

When I load my solution, I get following error message:

The C# project ... is targeting ".NETFramework,Version=4.5", which is not installed on this machine. To proceed, select an option below:

I choose for the second option, and I get following website: .NET SDKs for Visual Studio

This gives the following: list of .NET Frameworks:

4.7.1   Developer Pack, included in Visual Studio 2017   Runtime   Release Details
4.7     Developer Pack, included in Visual Studio 2017   Runtime   Release Details
4.6.2   Developer Pack, included in Visual Studio 2017   Runtime   Release Details
4.6.1   Developer Pack, included in Visual Studio 2017   Runtime   Release Details
4.6     Developer Pack, included in Visual Studio 2017   Runtime   Release Details
4.5.2   Developer Pack, included in Visual Studio 2017   Runtime   Release Details
3.5 SP1 Developer Pack, included in Visual Studio 2017   Runtime   Release Details

=> Where is 4.5?
I have already different times downloaded 4.5.2 version, Developer Pack as well as Runtime, but nothing changes.

So, after a while, I just close the dialog box about the missing target. I'm expecting to get a more readable error message, once I get to the compilation of the project.

Next to that, I've also investigated the installation of my PC (PC settings, Add and Remove Programs), this gives following list:

Microsoft .NET Core SDK - 2.1.4 (x64)
Microsoft .NET Framework 4.5 SDK
Microsoft .NET Framework 4.5.1 Multi-Targeting Pack (ENU)
Microsoft .NET Framework 4.5.1 SDK
Microsoft .NET Framework 4.5.2 Multi-Targeting Pack (ENU)
Microsoft .NET Framework 4.6 Targeting Pack
Microsoft .NET Framework 4.6.2 SDK
Microsoft .NET Framework 4.6.2 Targeting Pack
Microsoft .NET Framework 4.7 SDK
Microsoft .NET Framework 4.7 Targeting Pack

=> Ok, there seems not to be a targeting pack for 4.5 (only the SDK seems to be present), but what to do about it?

The error message speaks about retargeting my application, but that's out of the question: I'm the only person, having this problem, and modifying the configuration of a central application is not a solution.

The error message also speaks about the so-called "Global Assembly Cache" which will be used in place of reference assemblies. So, let's have a look at those things:

I seem to have two reference assemblies on my PC:

C:\Program Files\Reference Assemblies\Microsoft\Framework (seems only to contain "v3.0" and "v3.5" directories)
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.

The latter seems to contain a ".NETFramework" directory, which, at his turn, contains a "v4.5" subdirectory, containing quite some XML files.

The error message however states that those are not used, the "Global Assembly Cache (GAC)" is used instead. If I try finding this, I find references to gacutil, sn -k ... and other programs which are not found on my PC for the specied .Net framework.

If I look, using Google, for "Microsoft .Net Framework 4.5 Targeting Pack" (exact phrase), I get zero results.

So, in other words, I get a message about a missing piece of software on my PC. I get the opportunity to install it but the installation does nothing. Then I get a compilation error about this, which talks about a very general technology which seems not to exist following Google, the mostly used search engine on the internet. It mentions a technology (GAC) which might be used or not and who is found, either on C:\Program Files or C:\Program Files (x86), and its corresponding tool (gacutil) seems only to exist on my PC for other versions.

Can anybody give me a push in the right direction here?
Thanks in advance


Solution

  • Meanwhile I've solved the issue, and it comes down to a general truth in working with computers:

    When you have a problem, don't listen to what your computer tells you, but ask yourself what you were doing when the problem arose.

    In my case, it means the following:
    The problem popped up when I had upgraded my Visual Studio version (using the Visual Studio Installer), so the solution consisted of starting that Visual Studio Installer again, and check some more features to be installed (I've now checked so many of them that I can't figure out which one exactly solved my problem).

    The error message, preceeded by the dialog box, were just information about the PC internals which only led to ununderstandable sidetracks.