[英]WebRequest.Create throws System.NullReferenceException
[英]WebRequest.Create throws IOException “The specified registry key does not exist.”
我正在調用這行代碼來訪問azure服務器:
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
雖然我們有不同的調用堆棧,但此解決方案幫助HttpClient請求拋出IOException 。
您需要在注冊表中創建這些密鑰。
路徑:HKEY_LOCAL_MACHINE \\ SOFTWARE \\ Microsoft \\ .NETFramework
鍵:
name:“LegacyWPADSupport”類型:“dword”數據:00000000
路徑:HKEY_LOCAL_MACHINE \\ SOFTWARE \\ Wow6432Node \\ Microsoft \\ .NETFramework
鍵:
name:“LegacyWPADSupport”類型:“dword”數據:00000000
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.