2011-03-03 53 views
0

HttpWebRequest总是抛出超时异常,然后在Windows Vista SP1 32位下的单声道2.10中运行。相同的请求成功完成,然后在同一台机器上的Microsoft.Net下运行。这里如下代码:windows vista sp1下的单声道2.10 HttpWebRequest总是会抛出超时异常

string url = "http://maps.googleapis.com/maps/api/geocode/xml?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false"; 
try 
{ 
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); 
    Console.WriteLine(request.GetResponse()); 
} 
catch (Exception ex) 
{ 
    Console.WriteLine(ex.Message); 
} 

更新:

版本的单声道:

c:\Program Files\Mono-2.10\bin>mono -V 
Mono JIT compiler version 2.10 (tarball) 
Copyright (C) 2002-2011 Novell, Inc and Contributors. www.mono-project.com 
    TLS:   normal 
    SIGSEGV:  normal 
    Notification: Thread + polling 
    Architecture: x86 
    Disabled:  none 
    Misc:   softdebug 
    LLVM:   supported, not enabled. 
    GC:   Included Boehm (with typed GC and Parallel Mark) 
+1

请某人添加新标签单2.10 ... – 2011-03-03 11:04:30

+0

这是MonoDevelop的错误,然后在命令行中运行的程序运行正常。 – 2011-03-04 07:55:31

回答

0

我不能跟单2.10在Windows 7 X64的繁殖。

C:\用户\所有者\发展\ monobugs> C:\单 - 2.10 \ BIN \ mono.exe -V 单声道JIT编译版本2.10(压缩包) 版权(C)2002-2011 Novell公司,公司和贡献者。 www.mono-project.com TLS:正常 SIGSEGV:正常 通知:螺纹+轮询 架构:86 禁用:无 其他:softdebug LLVM:支持,尚未启用。 GC:包括伯姆(有类型的GC和并行标记)

C:\用户\用户\开发\ monobugs> C:\单-2.10 \ BIN \ mono.exe http.exe System.Net.HttpWebResponse

0

在单声道2.10.2主叫贝宝超时发生异常时,如果此码被用于:

HttpWebRequest objRequest = 
    (HttpWebRequest)WebRequest.Create("https://api-3t.sandbox.paypal.com/nvp"); 
objRequest.Timeout =15000; 
objRequest.Method = "POST"; 
objRequest.ContentLength = strPost.Length; 
using (StreamWriter myWriter = new 
    StreamWriter(objRequest.GetRequestStream())) 
      myWriter.Write(strPost); 

原因的异常在GetRequestStream():

System.Net.WebException: The request timed out 
     at System.Net.HttpWebRequest.GetRequestStream() [0x0005f] in 
    /usr/src/redhat/BUILD/mono-    2.10.2/mcs/class/System/System.Net/HttpWebRequest.cs:752 
     at NVPAPICaller.HttpCall (System.String NvpRequest) [0x00000] in   <filename 
    unknown>:0 

    --------------------------------------------------------------------  ------------ 
    Version information: Mono Runtime Version: 2.10.2 (tarball Mon Apr   18 
    18:57:39 UTC 2011); ASP.NET Version: 2.0.50727.1433 

你应该降级到Mono 2.10的第一个版本,它看起来像是在2.10.2中发生的。

2

不知道它是否会在这里相关,但我刚刚遇到同样的问题(好吧,无论如何相同的症状),并发现它是由在本机代码中创建的线程使用HttpWebRequest引起的。 (此线程稍后运行一个PInvoked托管代码的回调。)

我的问题已通过在托管代码中创建工作线程并将HttpWebRequest的所有用法转换为该问题得到解决。

我已经张贴这是一个mono bug