55

在 MS Visual Studio 中,我正在尝试将 Nuget 包安装到我的解决方案中。

当我选择“管理解决方案的 Nuget 包”选项并尝试安装包时,我收到消息“无法连接到远程服务器”。

我确实有 Internet 连接,所以不明白为什么我总是收到此消息。

有谁知道可以采取一些措施来纠正这个问题?

谢谢

4

22 回答 22

48

清除 HTTP_PROXY 对我有用。

让我自己修

重要提示:此部分、方法或任务包含告诉您如何修改注册表的步骤。但是,如果您不正确地修改注册表,则可能会出现严重问题。因此,请确保您认真执行这些步骤。为了增加保护,请在修改注册表之前备份它。然后,如果出现问题,您可以恢复注册表。有关如何备份和还原注册表的详细信息,请单击以下文章编号以查看 Microsoft 知识库中的文章:322756 如何在 Windows 中备份和还原注册表

要自行重置 Internet Explorer 代理设置,请执行以下步骤:

  1. 在 Windows XP 上,单击开始,或者在 Windows Vista 或 Windows 7 上,单击 ,然后单击运行。在 Windows 8 或 Windows 8.1 上,要访问“运行”命令,请按 Windows 徽标键 Windows 徽标键 + R。或者,从屏幕右边缘向内轻扫,然后点击搜索(或者如果您使用鼠标,请指向到屏幕的右上角,向下移动鼠标指针,然后单击搜索)。在搜索框中键入运行,然后点击或单击运行。
  2. 在运行文本框中,复制 (CTRL+C) 并粘贴 (CTRL+V) 或键入以下内容: reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 / F
  3. 单击确定。
  4. 在 Windows XP 上,单击开始 ,或者在 Windows Vista 或 Windows 7 上,单击 ,然后单击运行。在 Windows 8 或 Windows 8.1 上,要访问“运行”命令,请按 Windows 徽标键 Windows 徽标键 + R。或者,从屏幕右边缘向内轻扫,然后点击搜索(或者如果您使用鼠标,请指向到屏幕的右上角,向下移动鼠标指针,然后单击搜索)。在搜索框中键入运行,然后点击或单击运行。
  5. 在运行文本框中,复制 (CTRL+C) 并粘贴 (CTRL+V) 或键入以下内容: reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /f
  6. 单击确定。

来自http://support.microsoft.com/kb/2289942谢谢@Sandy

于 2013-03-23T15:45:47.997 回答
44

Solved. that's because Visual studio is using fiddler http connection.

all you have to do is to open fiddler=> fiddler option => connection => uncheck "act as system proxy on startup".

thats all!

于 2014-01-19T16:53:25.080 回答
26

This started happening to me quite randomly today on Visual Studio 2012. A bit simplistic but, after checking if the Nuget site itself was up and trying the Package Manager Console, my solution was to:

Close and reopen Visual Studio

Suddenly it could connect to the Nuget server again and download my much needed packages.

于 2014-03-19T17:02:42.713 回答
12

Tools -> Library Package Manager -> Package Manager Settings -> Clear Package Cache

That worked for me

于 2013-06-13T10:04:41.870 回答
6

Clearing the Proxy Cache in IE Fixed this for me. Use these two command lines in the command prompt (run as administrator)

reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f

then

reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /f

The details can be found at https://support.microsoft.com/en-us/kb/2289942

于 2015-05-26T11:47:59.780 回答
5

I solved it on mine by commenting out the

<system.net></system.net>

section from the devenv.exe.config located at

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe.config
于 2014-12-12T04:02:51.423 回答
4

Here's how I fixed this issue after none of the suggestions above worked:

Internet Explorer > Tools > Connections > Lan Settings
Uncheck 'Automatically Detect Settings' box. This solved the Nuget Package Manager issue for me. Additionally it fixed another connectivity problem I was having with a VMWare virtual desktop AND... it greatly increased speed in Internet Explorer when trying to connect to secure sites.

于 2015-11-07T22:29:53.737 回答
1

I had this issue with VS 2010 package restore even after updating the Nuget Package Manager to the latest and also unselecting all package sources I could. I was getting an error while enabling the Nuget Package Restore option on the solution.

I resolved this by using a different box that didn't have restricted https access to the nuget server. When I used VS 2012 from a different box to enable package restore, it worked fine. I believe it needs to be able to connect to the nuget online server to download the latest nuget.exe used during restore operations. So one option you can use is to perform the Enable Package Restore process from a server that has all the internet access necessary, and then check-in the changes. Once these changes are checked-in, you can then load the solution again from VS 2010 or VS 2012 and use the nuget restore capabilities.

Hope that helps!

于 2014-03-04T23:42:12.733 回答
1

Restarted Visual Studio twice solved my problem.

First, I restarted but it did not work. Then, I did almost everything but still didn't work.

Then, restarted again solved my problem.

于 2019-03-11T14:09:42.563 回答
0

I had the same symptoms, and apparently visual studio was using some proxy setting set up in IE. It turned out that my problem was one of the following:

  • My IE had been updated to IE 9, but the update wasn't completed because I hadn't completed the 'update wizard'
  • Some obscure proxy setting was set up in IE (a remnant of a selenium RC test run)

After completing the update wizard, and clearing all proxy settings, my NuGet package manager was working again.

于 2013-11-14T21:18:50.237 回答
0

Had the same issue, it was solution specific, and none of the above worked. I deleted the visual studio solution user options file (.suo) and restarted VS 2013 and now I can update and install packages again.

于 2014-10-01T20:26:57.510 回答
0

Finally resolved. I disabled an extension in Chrome. I had installed it to hide my real location.

于 2014-12-04T05:36:42.470 回答
0

To reset your Internet Explorer proxy settings yourself, follow these steps:1.On Windows XP, click Start, or on Windows Vista or Windows 7, click

2459687, and then click Run. On Windows 8 or Windows 8.1, to access the Run command, press the Windows logo key

Windows logo key+ R. Or, swipe in from the right edge of the screen, and then tap Search (or if you are using a mouse, point to the upper-right corner of the screen, move the mouse pointer down, and then click Search). Type Run in the search box, and then tap or click Run. 2.In the Run text box, copy (CTRL+C) and paste (CTRL+V) or type the following:

reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f

3.Click OK. 4.On Windows XP, click Start , or on Windows Vista or Windows 7, click

2459687, and then click Run. On Windows 8 or Windows 8.1, to access the Run command, press the Windows logo key

Windows logo key + R. Or, swipe in from the right edge of the screen, and then tap Search (or if you are using a mouse, point to the upper-right corner of the screen, move the mouse pointer down, and then click Search). Type Run in the search box, and then tap or click Run. 5.In the Run text box, copy (CTRL+C) and paste (CTRL+V) or type the following: reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /f

6.Click OK.

于 2014-12-19T19:00:44.580 回答
0

i could not install globalize in V.S. 2015 and after trying all the answers i tried this. I opened my project in V.S. 2013 and it worked 1st time. hope this helps somebody else

于 2015-11-03T18:51:17.517 回答
0

Modem re-start fixed my problem.!

于 2015-11-04T11:29:16.460 回答
0

In my case(visual studio 2012-windows10 OS) the problem was with security protocols. Only TLS 1.2 was the enabled protocol and TLS1.1 and TLS1.0 was disabled for some reason. So going into registry and making changes to enable TLS1.0 and TLS1.1 solved the problem.

To enable these protocols you can follow directions on here

于 2018-05-08T12:17:41.133 回答
0

I fixed it by uninstall the system proxifier : WideCap

于 2018-08-11T01:54:45.273 回答
0

That happened to me when I tried to use Visual Studio from home being connected via public WiFi and my work station was configured to block connections in/out from Internet to VS2017. Check you local firewall setting and ensure that you have Allow for VS2017 when on Public network. (in Windows Defender Firewall & Advanced Security)

于 2018-09-16T13:01:23.523 回答
0

nugget.org was blocked in my network for security reason so all the nugget packages are installed from Artifactory via JFrog. After configuring my nugget package manager setting to the link provided by my employer the problem is resolved.

于 2018-09-17T18:39:44.070 回答
0

One route that I haven't seen people mentioning is setting the proxy for Nuget in your user folder.

Browse to C:\Users[yourProfile]\AppData\Roaming\Nuget and change your Nuget.config file to the following:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <config>
   <add key="http proxy" value="http://yourProxy.yourCompany.org"/>
  </config>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
  </packageSources>
</configuration>

We set this setting and then Nuget immediately worked.

Ok, but now I get a credentials prompt!

If you also end up getting a credentials prompt when trying to load packages from Nuget in Visual Studio, you should try to manually browse to http://www.nuget.org/downloads. I've seen proxies like BlueCoat display a Content Filter Warning the first time someone visits a site, and since you can download content from Nuget, it get's flagged.

So you may need to browse there one time to click 'Accept Terms', and then you'll be able to access it.

于 2018-10-22T19:11:43.563 回答
-1

Internet 属性 -> LAN 设置 -> 取消选中“自动检测设置”

于 2013-04-21T17:08:56.110 回答
-2

Steps:

  1. Close Fiddler.
  2. Restart Visual Studio.
于 2015-06-03T06:32:04.303 回答