I'm using a simple webclient to retrieve some XML from a web service, I have this encased in a simple try, catch block (catching WebException). Like the following;
try
{
WebClient client = new WebClient();
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
client.DownloadStringAsync(new Uri("http://ip/services"));
}
catch (WebException e)
{
Debug.WriteLine(e.Message);
}
No if i change the IP address to one that isn't valid, i would of expected it to throw an exception and output the message to the debug window. But it doesn't, it seems the catch block isn't even getting executed. Nothing appears and the debug windows apart from the following;
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.Net.WebException' occurred in System.Windows.dll
A first chance exception of type 'System.Net.WebException' occurred in System.Windows.dll
My code looks right to me so I can't understand why exceptions are not being caught?