Xamarin.ios MonoTouch:在设备上运行时出现名称解析错误

Xamarin.ios MonoTouch:在设备上运行时出现名称解析错误,xamarin.ios,linq-to-xml,Xamarin.ios,Linq To Xml,在设备上调试我的应用程序时,我遇到了一个奇怪的问题 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: NameResolutionFailur

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

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
...

但它只在实际设备上。如果我在模拟器中运行它,它工作得很好。

A
namesolutionfailure
表示DNS错误,可能是因为设备没有互联网接入,没有DNS配置,或者至少与Mac(运行模拟器)使用的配置不同(例如Wifi、3G)

您可以从设备访问internet吗?(例如飞机模式)


如果是,您可以尝试从Safari在您的设备上访问
http://maps.googleapis.com
site查看设备上配置的DNS服务器是否可以找到主机。

Haha。我确信我已经在设备上激活了3G。原来我没有。至少这个问题有一个简单的解决办法。谢谢。iPhone设置中错误地手动禁用应用程序的手机数据也有同样的问题。。现在实现了一个对话框,允许ppl在出现此类错误时打开设置。。