Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Handling exceptions when using SOAP web reference - NameResolutionFailures

$
0
0

I am not having much luck with the following code:

try {
    var result = service.SomeWebMethod(param1);
} catch(Exception ex)
{
   // Do something
   Console.WriteLine(ex.Message);
}

service is a type generated automatically when adding a Web Reference to my web service. Everything normally works fine. I am testing that when the device is in airplane mode and this code get called an exception is thrown and crashes the app. I was expecting my exception to be caught and not crash the app. I get an unhandled exception in my Main.cs file.

The exceptions are thrown from this code:

// Dns.cs 
static void Error_11001 (string hostName)
{
throw new SocketException(11001, string.Format ("Could not resolve host '{0}'", hostName));
} 

I am seeing the Console.WriteLine(ex.Message), but I still get an exception caught around this:

try {
    UIApplication.Main (args, null, "AppDelegate");
} catch (Exception ex) {
   // End up here with NameResolutionFailure
}

Any suggestions on why I am still seeing the unhandled exception, when I think I am handling it normally?


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>