2

尝试在设备上调试我的应用程序时遇到一个奇怪的问题。

var url = "http://maps.googleapis.com/maps/api/geocode/xml?sensor=true&address=";
url += pin.Element("address").Value;
var address = XDocument.Load(url);

最后一行给了我这个错误:

System.Net.WebException: Error: NameResolutionFailure
at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00065] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:854
at System.Net.HttpWebRequest.GetResponse () [0x0000e] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:860
...

但这仅在实际设备上。如果我在模拟器中运行它,它会完美运行。

4

1 回答 1

5

A NameResolutionFailure means a DNS error, likely because the device does not have internet access, no DNS configured or at least a different configuration (e.g. Wifi, 3G) from the one your Mac (running the simulator) is using.

Can you access the internet from your device ? (e.g. airplane mode)

If so can you try to access, on your device from Safari, the http://maps.googleapis.com site to see if the DNS servers, configured on your device, can find the host.

于 2012-10-21T17:22:21.630 回答