Setup Visual Studio Proxy Setting

If you are working with Visual Studio behind your company proxy you may face many issues like failed to load nuget packages ,failed to load Visual Studio Extensions and Updates or failed to login with your Microsoft account within Visual Studio.

To solve these problems we have to let visual studio use our proxy correctly , to setup the proxy settings :

Open visual studio folder ,according to your version it may be something like .( C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE )

Open ( devenv.exe.config ) file and inside <> node add the bellow :

  <defaultProxy useDefaultCredentials="true" enabled="true"> 
    <proxy bypassonlocal="true" proxyaddress="http://[proxyURL]:[Port]" />

if  you got an error like :

System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send.......

it mean that you need to force the .NET framework to use TLS 1.2 when connecting using  HTTPS , to solve this error just create a new .reg file and put the following text in it and run it .

Windows Registry Editor Version 5.00



but based on you proxy you may face the : 407 error (Proxy authentication required) when Team Explorer trying to connect to your TFS server , to solve this issue you have to create a DLL with a custom proxy module that provides the credentials and the code will be something like :

using System;
using System.Net;
namespace Fayed.AuthProxy
    public class AuthProxyModule : IWebProxy
        ICredentials crendential = new NetworkCredential("proxy.user", "password");
        public ICredentials Credentials
                return crendential;
                crendential = value;
        public Uri GetProxy(Uri destination)
            return new Uri("http://proxy:8080", UriKind.Absolute);
        public bool IsBypassed(Uri host)
            return host.IsLoopback;

and the configuration will be like :

<system .net="">
  <module type="Fayed.AuthProxy.AuthProxyModule, Fayed.AuthProxy">

That's it :)

sources :