【问题标题】:Use WebRequest localy causes exceptions在本地使用 WebRequest 会导致异常
【发布时间】:2011-01-03 12:07:08
【问题描述】:

现在我正在处理我的第一个 Windows Mobile 项目,但我遇到了一个奇怪的问题..
我正在使用 WebRequest 从 Internet 下载一些图像 - 在我的手机上它可以工作,但在调试器中我有套接字异常。

string url    = "http://new.meteo.pl/um/metco/mgram_pict.php?ntype=0u&fdate=2010011006&row=381&col=199&lang=pl";
Stream stream = null;
WebRequest requestPic   = WebRequest.Create(url);
WebResponse responsePic = requestPic.GetResponse();
stream = responsePic.GetResponseStream();

return new System.Drawing.Bitmap(stream);

输出:

A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
The thread 0x167c46f6 has exited with code 0 (0x0).

如何强制我的本地实例获取这些图像?

【问题讨论】:

    标签: c# visual-studio windows-mobile webrequest


    【解决方案1】:

    如果您使用的是设备模拟器,只需配置网络信息即可。

    并确保它可以与外界连接(根据您的网络基础设施,这可能无法实现)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-22
      • 2023-03-25
      相关资源
      最近更新 更多