2017-01-30 65 views

回答

7

在您的安装目录中找到devenv.exe.config

现在打开此文本文件并在节点<system.net>内添加节点<defaultProxy>

<system.net> 
<defaultProxy useDefaultCredentials="true" enabled="true"> 
    <proxy bypassonlocal="true" proxyaddress="http://yourproxyaddress.net:8080" /> 
</defaultProxy> 
</system.net> 
+0

[需要代理授权](https://msdn.microsoft.com/en-us/library/dn771556.aspx) – lindexi

+0

当我这样做时我在启动时出现错误“合并配置失败” – Zanidd

0

你可以创建自己的代理身份验证模块喜欢这里descriped:

https://blogs.msdn.microsoft.com/rido/2010/05/06/how-to-connect-to-tfs-through-authenticated-web-proxy/

首先创建一个新的Visual C#项目 - >类库(.NET框架): 名称:ProxyModule(例如)。 USER,PWD和代理必须设置为正确的字符串值:

using System.Net; 
using System.Net.Sockets; 

namespace ProxyModule 
{ 
    public class AuthProxyModule : IWebProxy 
    { 
    ICredentials crendential = new NetworkCredential("USER", "PWD"); 

    public ICredentials Credentials 
    { 
     get 
     { 
      return crendential; 
     } 
     set 
     { 
      crendential = value; 
     } 
    } 

    public Uri GetProxy(Uri destination) 
    { 
     return new Uri("http://PROXY:8000", UriKind.Absolute); 
    } 

    public bool IsBypassed(Uri host) 
    { 
     return host.IsLoopback; 
    } 
    } 
} 

和创建 “ProxyModule.dll” 复制到 “... \ Common7 \ IDE” 文件夹中,VS 2015年:

C:\ Program Files文件(x86)的\微软的Visual Studio 14.0 \ Common7 \ IDE

或VS专业2017年:

C:\ Program Files文件(x86)的\微软的Visual Studio \ 2017年\专业\ Common7 \ IDE

然后,你必须在同一文件夹中的devenv.exe.config延长system.net部分:

<system.net> 
    <defaultProxy> 
    <module type="ProxyModule.AuthProxyModule, ProxyModule"/> 
    </defaultProxy> 
</system.net> 

如果您不想将使用代理在某些情况下可以延长方法“IsBypassed(Uri主持人)”。也许你可以检查自己的IP来启用或禁用代理(返回false以禁用代理)。

相关问题