Try-catch not working
c#, exception, try-catch, webclient
Solution
It sounds to me like you are running it under the debugger with "break on all managed exceptions" enabled. If that is the case the debugger would break on the line that threw the exception before the handler runs. Your handler is still working, the debugger is just letting you inspect the error beforehand.
Problem
``` class XWebClient : WebClient { protected override WebRequest GetWebRequest(Uri Url) { var Request = base.GetWebRequest(Url); ........... return Request; } } ``` Using: ``` try { XWebClient Client = new XWebClient(); Client.DownloadString(new Uri("badurl:100500")); } catch { MessageBox.Show("exception"); } ``` I was hoping to get a messagebox, but I get an unhandled exception. What am I doing wrong? Exception: System.NotSupportedexception Message: The URI prefix is not recognized Trace: ``` System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase) System.Net.WebRequest.Create(Uri requestUri) System.Net.WebClient.GetWebRequest(Uri address) XWebClient.GetWebRequest(Uri Url) в [path]\XWebClient.cs:строка 28 System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request) ```