NuGet Package Manager in Visual Studio: Unable to

2019-08-23 07:28发布

The Browse tab in Visual Studio NuGet Package Manager simply says "Error Occurred" with output:

[nuget.org] Unable to load the service index for source https://api.nuget.org/v3/index.json. Could not load file or assembly 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

I am on Visual Studio Community 15.7.2 and NuGet Package Manager 4.6.0. I've tried all the suggestions in similar questions to no avail. My Windows 10 recently updated, and I'm pretty sure it was working before that. I've tried repairing VS. I am on a home computer that (as far as I know) does not use a proxy.

Update:

I tried updating to .NET Framework 4.7.2. Didn't work. Although I don't think the problem is specific to NuGet(?), as when I go to Tools->Extensions and Updates->Updates I get the same message (with the dll version different perhaps due to my framework upgrade?):

Could not load file or assembly 'System.Net.Http, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

Update 2:

Manually installing a nuget package doesn't seem to work either:

Install-Package C:\Users\Admin\Downloads\anglesharp.0.9.9.2.nupkg

gives

Install-Package : Could not load file or assembly 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. At line:1 char:1 + Install-Package C:\Users\Admin\Downloads\anglesharp.0.9.9.2.nupkg + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Install-Package], FileNotFoundException + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Update 3:

I tried modifying my Visual Studio installation by added some extra components, which actually appears to have worked, in that I seem to be able to install packages through NuGet again. However, bizarrely, I came across these errors while logging in to Microsoft:

Login error 1 Login error 2

Inheritance security rules violated by type: 'System.Net.Http.WebRequestHandler'. Derived types must either match the security accessibility of the base type or be less accessible.

So I'm left wondering if I'm playing a game of whack-a-mole...

1条回答
爷、活的狠高调
2楼-- · 2019-08-23 08:16

You can try to set proxy options, although you are not using ... maybe it will help.

1.Go to your Visual Studio install location as below - C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE

2.Open devenv.exe.config file as an Administrator. Add defaultProxy tags as below, within the existing system.net tag -

<system.net>
    <defaultProxy enabled="true" useDefaultCredentials="true">
        <proxy usesystemdefault="true" bypassonlocal="true" />
    </defaultProxy>
    <settings>
        <ipv6 enabled="true"/>
    </settings>
</system.net>

3.Restart VS.

查看更多
登录 后发表回答