How to set proxy in visual studio 2015

后端 未结 3 717
夕颜
夕颜 2020-12-31 21:15

I\'m Using Visual Studio 2015 for Xamarin app development and I\'m working behind corporate proxy, I need to set the proxy(http proxy) to the Visual studio 2015, so how coul

3条回答
  •  别那么骄傲
    2020-12-31 22:12

    You could create your own proxy authentication module like descriped here:

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

    First create a new Visual C# Project -> Class Library (.Net Framework): Name: ProxyModule (for example). USER, PWD and PROXY must be set to the correct string values:

    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;
        }
      }
    }
    

    and copy the created "ProxyModule.dll" to the "...\Common7\IDE" folder, VS 2015:

    C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE

    or VS professional 2017:

    C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE

    Then you must extend the system.net part in the devenv.exe.config in the same folder:

    
      
        
      
    
    

    If you don´t want to use the proxy in some cases you can extend the method "IsBypassed(Uri host)". Maybe you could check your own IP to enable or disable the proxy (return false to disable the proxy).

提交回复
热议问题