'Can't Install Nuget Package

I am trying to install System.Runtime.Handles so I can use SafeAccessTokenHandle and RunImpersonated, however when I try to install the package I get the error :

Could not install package 'System.Runtime.Handles 4.3.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5.2', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

I have done some research and I do not believe there is a .NETFramework, Version=v4.3.0. Does anybody have an idea on how to install this package?



Solution 1:[1]

I have done some research and I do not believe there is a .NETFramework, Version=v4.3.0. Does anybody have an idea on how to install this package?

First, you have to make sure the version of NuGet Package Manager for Visual Studio 2013 is the latest version 2.12.0.817, not the default version 2.8. You can check it from Tools->Extensions and Updates->Installed.

That because this nuget package require the NuGet 2.12 or higher.

enter image description here

Second, you should make sure you have installed the .net 4.6 and above. You should not change the framework version by unloading the project, opening the project file, changing the target framework, and then reloading the file. In this way, Visual Studio can not help to check if you have install that target framework. You should change it by right on the project select Properties->Application->Target framework:

enter image description here

If you do not have target framework .net 46, you can click the Install other frameworks to install it. For this question, you can just change your target framework to 4.7.1 directly.

Hope this helps.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Leo Liu-MSFT