An exception occurred during a WebClient requ…
2018-06-18 04:55:51来源:未知 阅读 ()
System.Net.WebException was caught
HResult=-2146233079
Message=An exception occurred during a WebClient request.
Source=System
StackTrace:
at System.Net.WebClient.OpenRead(Uri address)
at System.Net.WebClient.OpenRead(String address)
at Client.Program.GetAllEmployees(String contentType, String accept) in h:\帮助页面与自动消息格式(JSONXML)选择\Client\Program.cs:line 62
InnerException: System.Configuration.ConfigurationErrorsException
HResult=-2146232062
Message=Error creating the Web Proxy specified in the 'system.net/defaultProxy' configuration section.
Source=System
BareMessage=Error creating the Web Proxy specified in the 'system.net/defaultProxy' configuration section.
Line=0
StackTrace:
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.Net.WebRequest.Create(Uri requestUri)
at System.Net.WebClient.GetWebRequest(Uri address)
at System.Net.WebClient.OpenRead(Uri address)
InnerException: System.Net.Sockets.SocketException
HResult=-2147467259
Message=An invalid argument was supplied
Source=System
ErrorCode=10022
NativeErrorCode=10022
StackTrace:
at System.Net.SafeCloseSocketAndEvent.CreateWSASocketWithEvent(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType, Boolean autoReset, Boolean signaled)
at System.Net.NetworkAddressChangePolled..ctor()
at System.Net.AutoWebProxyScriptEngine.AutoDetector.Initialize()
at System.Net.AutoWebProxyScriptEngine.AutoDetector.get_CurrentAutoDetector()
at System.Net.AutoWebProxyScriptEngine..ctor(WebProxy proxy, Boolean useRegistry)
at System.Net.WebProxy.UnsafeUpdateFromRegistry()
at System.Net.WebProxy..ctor(Boolean enableAutoproxy)
at System.Net.Configuration.DefaultProxySectionInternal..ctor(DefaultProxySection section)
at System.Net.Configuration.DefaultProxySectionInternal.GetSection()
InnerException:
上述的错误来自于下面的代码:
WebClient webClient = new WebClient(); var stream = webClient.OpenRead("http://www.cnblogs.com/"); using (StreamReader reader = new StreamReader(stream)) { Console.WriteLine(reader.ReadToEnd()); }
上面的错误让我纠结了好久,仅仅是一个简单的webclient请求,怎么都不通??
百度了一个办法?
http://codebender.denniland.com/system-net-webexception-an-exception-occurred-during-a-webclient-request/
试了,还是不行,看到了system.net/defaultProxy 关键词,以为是公司网络问题,于是下班之后在家里的网络试了一下,
竟然代码通过了,所以我的怀疑是没问题的,
但是毕竟要在公司开发啊,回到公司,果然错误依旧
然后找了同事帮我看,看着看着 ,灵机一动 我想起来了,代码不是放在本地,是放在一个共享里,
。。。。。。。。。
这个错误的原因来的太纠结了,果然 把代码拷贝到本地,错误也就没了,
真是自己折磨自己啊
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
- Caused by: java.sql.SQLSyntaxErrorException: Unknown col 2020-06-07
- 500 ZuulException: Forwarding error 2020-06-01
- org.apache.jasper.JasperException: java.lang.NullPointer 2020-05-21
- Java中Error和Exception的异同以及运行时异常(Runtime exce 2020-05-13
- java.lang.IllegalStateException: getOutputStream() has a 2020-05-08
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash