2013-03-25 74 views
6

我打电话这行代码去蔚蓝服务器:WebRequest.Create抛出IOException“指定的注册表项不存在。”

var request = (HttpWebRequest)WebRequest.Create(uri); 

和接收此异常。 有人知道如何管理它吗?

mscorlib.dll!Microsoft.Win32.RegistryKey.Win32Error(int errorCode, string str) + 0x189 bytes  
mscorlib.dll!Microsoft.Win32.RegistryKey.GetValueKind(string name) + 0x7f bytes 
System.dll!System.Net.HybridWebProxyFinder.InitializeFallbackSettings() + 0xb8 bytes  
System.dll!System.Net.HybridWebProxyFinder.HybridWebProxyFinder() + 0x1e bytes 
[Native to Managed Transition] 
[Managed to Native Transition] 
System.dll!System.Net.HybridWebProxyFinder.HybridWebProxyFinder(System.Net.AutoWebProxyScriptEngine engine) + 0x37 bytes  
System.dll!System.Net.AutoWebProxyScriptEngine.AutoWebProxyScriptEngine(System.Net.WebProxy proxy, bool useRegistry) + 0x190 bytes 
System.dll!System.Net.WebProxy.UnsafeUpdateFromRegistry() + 0x67 bytes 
System.dll!System.Net.WebProxy.WebProxy(bool enableAutoproxy) + 0x44 bytes 
System.dll!System.Net.Configuration.DefaultProxySectionInternal.DefaultProxySectionInternal(System.Net.Configuration.DefaultProxySection section) + 0x3d9 bytes 
System.dll!System.Net.Configuration.DefaultProxySectionInternal.GetSection() + 0xbe bytes 
System.dll!System.Net.WebRequest.InternalDefaultWebProxy.get() + 0x7e bytes 
System.dll!System.Net.HttpWebRequest.HttpWebRequest(System.Uri uri, System.Net.ServicePoint servicePoint) + 0x18d bytes 
System.dll!System.Net.HttpRequestCreator.Create(System.Uri Uri) + 0x50 bytes  
System.dll!System.Net.WebRequest.Create(System.Uri requestUri, bool useUriBase) + 0x2ec bytes 
System.dll!System.Net.WebRequest.Create(string requestUriString) + 0xa3 bytes 
+0

好吧,似乎LegacyWPADSupport的解决方案有所帮助,虽然我们有不同的调用堆栈。 – 2013-03-25 15:58:40

+0

你有没有解决这个问题? – skimania 2013-04-04 19:48:14

+2

是的。这个解决方案有助于http://stackoverflow.com/questions/13141434/httpclient-request-throws-ioexception/13745641#13745641,尽管我们有不同的调用堆栈。 – 2013-04-08 14:08:20

回答

3

该解决方案有助于HttpClient request throws IOException,尽管我们有不同的调用堆栈。

您需要在注册表中创建这些密钥。

路径:HKEY_LOCAL_MACHINE \ SOFTWARE \微软\ .NETFramework

重点:

名称: “LegacyWPADSupport” 型: “DWORD” 的数据:00000000

路径:HKEY_LOCAL_MACHINE \ SOFTWARE \ Wow6432Node \微软\ .NETFramework

重点:

名称: “LegacyWPADSupport” 型: “DWORD” 的数据:00000000

+2

为了完整性,钥匙在: HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ .NETFramework和 HKEY_LOCAL_MACHINE \ SOFTWARE \ Wow6432Node \ Microsoft \ .NETFramework – Rob 2014-09-25 11:37:37

+0

谢谢。格式化在点(\。)之前已经吃掉了斜线。我编辑了答案,以便正确显示。 – 2014-09-25 11:43:52