7

I have a CLR enabled .NET app that accesses a webservice and writes an xml file to a webserver for a SQLServer SSIS package to digest. Everything works fine on the development servers, but the production server returns the following error:

Error creating the Web Proxy specified in the 'system.net/defaultProxy' configuration section.: at System.Net.Configuration.DefaultProxySectionInternal.GetSection() at System.Net.WebRequest.get_InternalDefaultWebProxy() at System.Net.HttpWebRequest..ctor(Uri uri, ServicePoint servicePoint) at System.Net.HttpRequestCreator.Create(Uri Uri) at System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase) at System.Web.Services.Protocols.WebClientProtocol.GetWebRequest(Uri uri) at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebRequest(Uri uri) at System.Web.Services.Protocols.SoapHttpClientProtocol.GetWebRequest(Uri uri) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at MyDBProj.com.dmsintegration.secure.VehicleInventoryService.RetriveVehicleInventory(RetrieveAllRecordsRequest request) at UserDefinedFunctions.LoadDMSFile(String dealer_id, String dms_username, String dms_password, String dms_location_id)

There are no differences between the server OS versions or the SQLServer versions. We are using Windows Server 2003 R2 and SQL Server 2005. I believe it must be a configuration on the server itself but I cannot find any differences between the servers. Neither server runs a software firewall.

Full Exception:

System.Configuration.ConfigurationErrorsException: Error creating the Web Proxy specified in the 'system.net/defaultProxy' configuration section. ---> System.DllNotFoundException: Unable to load DLL 'rasapi32.dll': A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A)
at System.Net.UnsafeNclNativeMethods.RasHelper.RasEnumConnections(RASCONN[] lprasconn, UInt32& lpcb, UInt32& lpcConnections) at System.Net.UnsafeNclNativeMethods.RasHelper.GetCurrentConnectoid() at System.Net.AutoWebProxyScriptEngine.AutoDetector.Initialize() at System.Net.AutoWebProxyScriptEngine..ctor(WebProxy proxy, Boolean useRegistry) at System.Net.WebProxy.UnsafeUpdateFromRegistry() at System.Net.Configuration.DefaultProxySectionInternal..ctor(DefaultProxySection section) at System.Net.Configuration.DefaultProxySectionInternal.GetSection() --- End of inner exception stack trace --- at System.Net.Configuration.DefaultProxySectionInternal.GetSection() at System.Net.WebRequest.get_InternalDefaultWebProxy() at System.Net.HttpWebRequest..ctor(Uri uri, ServicePoint servicePoint) at System.Net.HttpRequestCreator.Create(Uri Uri) at System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase) at System.Web.Services.Protocols.WebClientProtocol.GetWebRequest(Uri uri) at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebRequest(Uri uri) at System.Web.Services.Protocols.SoapHttpClientProtocol.GetWebRequest(Uri uri) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at MyDBProj.com.dmsintegration.secure.VehicleInventoryService.RetriveVehicleInventory(RetrieveAllRecordsRequest request) at UserDefinedFunctions.LoadDMSFile(String dealer_id, String dms_username, String dms_password, String dms_location_id)

JJJ
  • 31,545
  • 20
  • 84
  • 99
James
  • 109
  • 1
  • 1
  • 7
  • What is a CLR-enabled .NET application? I've been working with .NET since before .NET 1.0 beta 1, and I don't think I've ever heard of that. – John Saunders Jul 21 '09 at 17:36
  • This is just a C# assembly that has been loaded into the SQL Server to be used by a function and stored procedure on the server. – James Jul 21 '09 at 18:34

4 Answers4

4

We had exactly the same error message when calling a Web service from a .Net Winform application.

In our case the error occurred for one user, but not for the other (with local admin permissions) on the same server.

In fact it has nothing to with WCF; you would have the same error when calling a simple web page from your app. The executing user account is not allowed to open a Web Proxy connection.

We solved the problem by moving the application into C:\Program Files. For a reason I can't yet explain exactly, from this folder the same user can create the Proxy.

Any insight on this would be welcome.

flip
  • 1,031
  • 9
  • 25
  • I was having this same issue and this actually worked for me. I had to run the application directly inside the Program Files folder. This led me to discover the real issue. For some reason, the application was getting installed by default to run under compatibility mode for Windows 2000. Once I unchecked that (Right-click->Properties->Compatibility), it was able to connect to the service. – dbooth Mar 30 '12 at 15:49
  • Same here, was running from a network file system, could not make a simple HTTP request. – Cameron Mar 03 '15 at 19:42
2

we had faced the same issue. eror creating the Web Proxy specified in the 'system.net/defaultProxy' configuration section.

I resolved it by correcting the incorrect entries in config files in website.Just make sure that all tags are opned and closed correctly.it may reosolve your issue.

SHIBIN
  • 191
  • 1
  • 5
1

James, look closely:

Error creating the Web Proxy specified in the 'system.net/defaultProxy' configuration section

John Saunders
  • 157,405
  • 24
  • 229
  • 388
  • Yes... All the servers have the same config in the web.config. The internet connection settings concerning web proxies are identical on all the servers. I am trying to figure out why the error only occurs on one server when all of these configs are the same. – James Jul 21 '09 at 16:05
  • What is specified in the **'system.net/defaultProxy'** section on all the machines? – John Saunders Jul 21 '09 at 16:43
  • And did you consider machine.config and the base web.config, and all the web.configs up the hierarchy? Are the sites all in the same virtual location on all machines? – John Saunders Jul 21 '09 at 16:44
  • The snippet I posted in my comment is exactly what is in the config file. only appears in the base web.config file on each server. In each case the clr assembly is loaded to the SQL server with the same permissions. – James Jul 21 '09 at 17:24
  • I guess I didn't see the code in your comment at first. You should update your question with that information. Suggestion: can you pick a single proxy and set it explicitly? "usesystemdefault" means it could be different on each system, and you'd have to find out why. Also, is that the entire exception? The output of ex.ToString()? I'd be curious to know if there was an InnerException. – John Saunders Jul 21 '09 at 17:35
  • The InnerException reads: 'System.DllNotFoundException: Unable to load DLL 'rasapi32.dll': A dynamic link library (DLL) initialization routine failed.' rasapi32.dll is present in the same location on all the servers. The only common remedy that I have found on Google is to change usesystemdefault to false. I have done that on all the servers with the same results. – James Jul 21 '09 at 18:33
  • James, please do: try { } catch (Exception ex){Console.WriteLine(ex.ToString());} and post ex.ToString(). There may be more inner's, and the stack traces may be useful. rasapi32.dll will be the problem. It's not making this up. – John Saunders Jul 21 '09 at 19:05
0

This error happened to me when attempting to access Source Server from WinDBG. I was referencing TF.EXE in the C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ folder from my srcsrv.ini file.

I made a copy of tf.exe / tf.exe.config and placed it in the folder with WinDBG, and it worked fine.

It turned out that an earlier download of symbols from the Microsoft Symbol Store had put folders winhttp.dll, etc., in the C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE folder, and those were being read. That made tf.exe unable to find and load those dlls. What should have happened is that tf.exe did not find them there, but instead loaded them from the c:\Windows\Syswow64 folder.

Process Monitor from SysInternals is your friend!

Nalaka526
  • 10,062
  • 20
  • 77
  • 115