Skip to the content.

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 <system.net> node add the bellow :

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

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

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319]
"SchUseStrongCrypto"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319]
"SchUseStrongCrypto"=dword:00000001

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
        {
            get
            {
                return crendential;
            }
            set
            {
                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="">
 <defaultproxy>
    <module type="Fayed.AuthProxy.AuthProxyModule, Fayed.AuthProxy">
    </module>
 </defaultproxy>
</system.net>

That’s it :)

source: