使用了与请求的协议不兼容的地址的解决办法。

来源:互联网 发布:bim软件nbims 编辑:程序博客网 时间:2024/05/02 14:07

       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, 然后重启,问题解决。