1

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?

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
parrigin777
  • 178
  • 1
  • 1
  • 10
  • 2
    4.3.0 refers to `System.Runtime.Handles` version; check [here](https://www.nuget.org/packages/System.Runtime.Handles/): the package requires .NET 4.6.0. You need to update your project configuration to support that version. – Fer García Nov 12 '18 at 19:42
  • Okay I tried to install .NET 4.6.0 and it said it was already installed. So I checked and it looks like I have 4.7.1 installed. When I change my project to use 4.6.0 it tells me I have to install it. – parrigin777 Nov 12 '18 at 20:03
  • @parrigin777 you might need the "targeting pack": https://www.microsoft.com/en-us/download/details.aspx?id=48136 – Marc Gravell Nov 12 '18 at 20:12
  • @parrigin777 two questions: what's your Visual Studio version?, and how are you changing the .NET framework target version of your project? – Fer García Nov 12 '18 at 20:17
  • @MarcGravell I downloaded and installed both executables via the link provided and I am still prompted saying I need to install v4.6.0 – parrigin777 Nov 12 '18 at 20:18
  • @FerGarcía I am using Visual Studio 2013 and I change the framework version by unloading the project, opening the project file, changing the target framework, and then reloading the file. – parrigin777 Nov 12 '18 at 20:20
  • @FerGarcía I hate to say it, but it is increasingly hard for us to offer guidance on VS2013... in dev terms, that's pretty old – Marc Gravell Nov 12 '18 at 20:42

1 Answers1

2

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.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • I did that and now I get the error message at runtime: Parser Error Message: The 'targetFramework' attribute in the element of the Web.config file is used only to target version 4.0 and later of the .NET Framework (for example, ''). The 'targetFramework' attribute currently references a version that is later than the installed version of the .NET Framework. Specify a valid target version of the .NET Framework, or install the required version of the .NET Framework. – parrigin777 Nov 15 '18 at 21:02
  • 1
    @parrigin777, Sorry to reply so late. It seems your website project is targeting v4.6 of the .Net Framework but your hosting provider has not yet installed this version. Check https://stackoverflow.com/questions/33412042/configuration-error-related-to-targetframework-in-web-config/41588281 – Leo Liu Nov 21 '18 at 06:24