Visual Studio 中的 NuGet 包管理器:无法加载源 https://api.nuget.org/v3/index.json 的服务索引 [英] NuGet Package Manager in Visual Studio: Unable to load the service index for source https://api.nuget.org/v3/index.json

查看:96
本文介绍了Visual Studio 中的 NuGet 包管理器:无法加载源 https://api.nuget.org/v3/index.json 的服务索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Visual Studio NuGet 包管理器中的浏览"选项卡简单地显示发生错误"并输出:

<块引用>

[nuget.org] 无法加载源的服务索引

<块引用>

类型违反了继承安全规则:System.Net.Http.WebRequestHandler".派生类型必须与基类型的安全可访问性相匹配或不易访问.

所以我想知道我是不是在玩打地鼠游戏...

解决方案

您可以尝试设置代理选项,尽管您没有使用...也许会有所帮助.

1.转到您的 Visual Studio 安装位置,如下所示 -C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE

2.以管理员身份打开 devenv.exe.config 文件.在现有的 system.net 标签中添加如下的 defaultProxy 标签 -

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

3.重启VS.

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:

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...

解决方案

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.

这篇关于Visual Studio 中的 NuGet 包管理器:无法加载源 https://api.nuget.org/v3/index.json 的服务索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆