尝试将数据发布到服务器C时出现异常#

时间:2016-05-29 12:42:33

标签: c# .net .net-micro-framework

我正在使用C#,。net micro framework 4.3。我试图将maek空帖发布到服务器,但我总是得到例外:

  

程序已开始POST到   :http://api.lyncagent.com/sendim?dnmf=yes&sender=xxxx&recipient=yyyy&message=ferastanan&priority=Normal&subject=NetMF   POST完成。线程''(0x3)已退出,代码为0   (为0x0)。       #### Exception System.Net.Sockets.SocketException - CLR_E_FAIL(7)####       #### 信息:       #### Microsoft.SPOT.Net.SocketNative :: getaddrinfo [IP:0000] ####       #### System.Net.Dns :: GetHostEntry [IP:0008] ####       #### System.Net.HttpWebRequest :: EstablishConnection [IP:00e1] ####       #### System.Net.HttpWebRequest :: SubmitRequest [IP:0019] ####       #### System.Net.HttpWebRequest :: GetResponse [IP:000c] ####       #### Gadgeteer.Networking.HttpRequest :: HandleRequestSync [IP:01a8] ####       #### SocketException ErrorCode = 10060       #### SocketException ErrorCode = 10060发生了'System.Net.Sockets.SocketException'类型的第一次机会异常   Microsoft.SPOT.Net.dll       #### SocketException ErrorCode = 10060       #### SocketException ErrorCode = 10060       #### Exception System.Net.WebException - 0x00000000(7)####       ####消息:主机不可用       #### System.Net.HttpWebRequest :: EstablishConnection [IP:00f1] ####       #### System.Net.HttpWebRequest :: SubmitRequest [IP:0019] ####       #### System.Net.HttpWebRequest :: GetResponse [IP:000c] ####       #### Gadgeteer.Networking.HttpRequest :: HandleRequestSync [IP:01a8] ####类型'System.Net.WebException'的第一次机会异常   发生在System.Http.dll中       #### Exception System.Net.WebException - 0x00000000(7)####       #### 信息:       #### System.Net.HttpWebRequest :: GetResponse [IP:00d3] ####       #### Gadgeteer.Networking.HttpRequest :: HandleRequestSync [IP:01a8] ####类型'System.Net.WebException'的第一次机会异常   发生在System.Http.dll

中      

连接到Internet时发生异常。请做出来   确保使用有效的URL并建立网络连接。

这是代码:

string url = "http://api.lyncagent.com/sendim?dnmf=yes&sender=xxxx&recipient=yyyy&message=" + "ferastanan" + "&priority=Normal&subject=NetMF";
        Debug.Print("POST to :" + url);
        POSTContent emptyPost = new POSTContent();
        var req = HttpHelper.CreateHttpPostRequest(url, emptyPost, "text/plain");


        req.ResponseReceived += new HttpRequest.ResponseHandler(req_ResponseReceived);
        req.SendRequest();
        Debug.Print("POST complete.");

0 个答案:

没有答案