[mono-android] NameResolutionFailure exception
Jonathan Pryor
jonp at xamarin.com
Wed Jun 6 19:00:40 UTC 2012
On Jun 4, 2012, at 4:01 AM, vkMahesh wrote:
> I am also facing the same problem. can anyone help me on this?
Is this a Debug app or a Release app? On hardware or an emulator?
Sanity test: on your target device, open the Browser app and try to go to the URL that is generating a NameResolutionFailure. Does it work within Browser?
Is the URL an http or an https url?
Your app needs INTERNET permission in order to access remote sites. This is added by default in Debug builds but no Release builds, so you should check your project settings to ensure that the INTERNET permission is there.
I've found that the emulator is often flaky regarding whether the network is connected or not. F8 will toggle network availability within the emulator; it's possible that the network has been disabled, and you need to enable it.
If the URL is an https URL, the site needs to have an SSL certificate that doesn't require user authorization, i.e. if you use the Browser app you CANNOT be prompted to accept the SSL certificate. If you are prompted (e.g. a self-signed cert), you will need to set the System.Net.ServicePointManager.ServerCertificateValidationCallback property:
http://msdn.microsoft.com/en-us/library/system.net.servicepointmanager.servercertificatevalidationcallback.aspx
// Warning: accepts ALL certificates.
// DO NOT USE unless you like being 0wned
System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, errors) => {
return true;
};
As always, Android Debug Log output is useful in determining what the error is:
http://docs.xamarin.com/android/advanced_topics/android_debug_log
- Jon
More information about the Monodroid
mailing list