I have an issue with VS2010 where the debugger stops with an Unhandled Exception. However, the exception is definitely handled. In fact, if I put code in the catch block, I'll hit it when I press F5. In Debug -> Exceptions, I definitely do not have the "Thrown" checkbox checked, so IMO there is absolutely no reason for the unhandled exception dialog to pop up...
I can't post the exact code, but will work on a sample soon. The basic idea behind the offending code section is that I have a thread that talks to hardware, and if I have an error talking to it, then I throw a HardwareException. The thread is launched with BeginInvoke, and the exception is caught in the callback handler when I call EndInvoke.
When the exception is thrown in the debugger, I get a messagebox that says 'HardwareException not handled by user code". But it is!!!
EDIT -- Well, this is driving me crazy. I've got sample code that is representative of the code I have in my application, and it looks like this:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.Remoting.Messaging; using System.Threading; namespace ConsoleApplication1 { public class HardwareException : ApplicationException { public HardwareException( string message) : base(message) {} } class Program { delegate void HardwareTestDelegate(); static void Main(string[] args) { HardwareTestDelegate d = new HardwareTestDelegate( HardwareTestThread); d.BeginInvoke( HardwareTestComplete, null); while( true); } static void HardwareTestThread() { throw new HardwareException( "this is a test"); } static void HardwareTestComplete( IAsyncResult iar) { try { AsyncResult ar = (AsyncResult)iar; HardwareTestDelegate caller = (HardwareTestDelegate)ar.AsyncDelegate; caller.EndInvoke( iar); } catch( Exception ex) { Console.WriteLine( "Should see this line without getting an unhandled exception message in the IDE"); } } } } I throw my HardwareException from the thread, and then handle the exception when EndInvoke is called. I guess Murphy was right, because when I run this sample code, it does what I expect -- i.e. no unhandled exception error message pops up in the IDE!