1. 程式人生 > >使用了與請求的協議不相容的地址的解決辦法。

使用了與請求的協議不相容的地址的解決辦法。

       C#中使用HttpWebRequest,WebClient等進行網路操作有時候會提示異常,大致如:

System.Net.WebException: 在 WebClient 請求期間發生異常。 ---> System.Configuration.ConfigurationErrorsException: 建立在“system.net/defaultProxy”配置節中指定的 Web 代理時出錯。 ---> System.Net.Sockets.SocketException: 使用了與請求的協議不相容的地址。
在 System.Net.SafeCloseSocketAndEvent.CreateWSASocketWithEvent(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType, Boolean autoReset, Boolean signaled)
在 System.Net.NetworkAddressChangePolled..ctor()
在 System.Net.AutoWebProxyScriptEngine.AutoDetector.Initialize()
在 System.Net.AutoWebProxyScriptEngine.AutoDetector.get_CurrentAutoDetector()
在 System.Net.AutoWebProxyScriptEngine..ctor(WebProxy proxy, Boolean useRegistry)
在 System.Net.WebProxy.UnsafeUpdateFromRegistry()
在 System.Net.WebProxy..ctor(Boolean enableAutoproxy)
在 System.Net.Configuration.DefaultProxySectionInternal..ctor(DefaultProxySection section)
在 System.Net.Configuration.DefaultProxySectionInternal.GetSection()

         有的人使用防毒軟體防毒後可能就出現這個問題了,看起來是網路相關的問題,可以通過修復登錄檔中的網路連線設定來解決,命令列下執行命令:

netsh winsock reset, 然後重啟,問題解決。