How to continue execution after an exception?<p>hi,</p> <p>Sometimes I need to end the current process without reporting an error in my windows application, so I design an AbortException class and handle this exception in Application.ThreadException event.  It works like a &quot;silent exception&quot;.  Everytime I need to stop a process without showing a message, I throw an AbortException.  But it is really a problem when I need to continue debugging after this exception.  Does anyone know how to avoid the Exception dialog box from reappearing?  I found a related topic on <a title="http://msdn2.microsoft.com/en-us/library/ky9bw27e.aspx" href="http://msdn2.microsoft.com/en-us/library/ky9bw27e.aspx">http://msdn2.microsoft.com/en-us/library/ky9bw27e.aspx</a> but it didn't help...</p> <p>Thanks.</p> <p>Stanley</p>© 2009 Microsoft Corporation. All rights reserved.Thu, 19 Jun 2008 00:15:52 Z2ba45746-64b0-4ac7-98fe-268bd80ff939http://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/2ba45746-64b0-4ac7-98fe-268bd80ff939#2ba45746-64b0-4ac7-98fe-268bd80ff939http://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/2ba45746-64b0-4ac7-98fe-268bd80ff939#2ba45746-64b0-4ac7-98fe-268bd80ff939Stanley Chou_http://social.msdn.microsoft.com/Profile/en-US/?user=Stanley%20Chou_How to continue execution after an exception?<p>hi,</p> <p>Sometimes I need to end the current process without reporting an error in my windows application, so I design an AbortException class and handle this exception in Application.ThreadException event.  It works like a &quot;silent exception&quot;.  Everytime I need to stop a process without showing a message, I throw an AbortException.  But it is really a problem when I need to continue debugging after this exception.  Does anyone know how to avoid the Exception dialog box from reappearing?  I found a related topic on <a title="http://msdn2.microsoft.com/en-us/library/ky9bw27e.aspx" href="http://msdn2.microsoft.com/en-us/library/ky9bw27e.aspx">http://msdn2.microsoft.com/en-us/library/ky9bw27e.aspx</a> but it didn't help...</p> <p>Thanks.</p> <p>Stanley</p>Wed, 22 Nov 2006 07:18:52 Z2007-01-05T18:38:18Zhttp://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/2ba45746-64b0-4ac7-98fe-268bd80ff939#a9d97c91-cbf0-4ab2-b5ac-35833dc3c3f4http://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/2ba45746-64b0-4ac7-98fe-268bd80ff939#a9d97c91-cbf0-4ab2-b5ac-35833dc3c3f4Azeem Khan - MSFThttp://social.msdn.microsoft.com/Profile/en-US/?user=Azeem%20Khan%20-%20MSFTHow to continue execution after an exception?<p>Stanley,</p> <p>I assume you are talking about the Exception Assistant (EA) dialog that comes up. The EA causes an unwind to the point just before exception gets thrown. So continuing will cause exception to be thrown again. You can disable this behavior by disabling Tools -&gt; Options -&gt; Debugging -&gt; General -&gt; Unwind callstack on unhandled exception or you can disable Exception Assistant itself. This should let you continue from unhandled exceptions.</p> <p>If you have stopping on first-chance exceptions enabled (see Debug -&gt; Exceptions, Thrown column) then debugger will stop when an exception is thrown but you should be able to continue.  You can disable this as well from the Exceptions dialog. Note that the debugger always stops for unhandled exceptions but you can continue if you have above EA option or EA disabled. HTH.</p> <p>Azeem Khan</p> <p>Visual Studio Debugger.</p>Wed, 22 Nov 2006 18:32:01 Z2006-11-22T18:32:01Zhttp://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/2ba45746-64b0-4ac7-98fe-268bd80ff939#c7743bec-9050-4bdc-ac82-a24d67a11bbfhttp://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/2ba45746-64b0-4ac7-98fe-268bd80ff939#c7743bec-9050-4bdc-ac82-a24d67a11bbfStanley Chou_http://social.msdn.microsoft.com/Profile/en-US/?user=Stanley%20Chou_How to continue execution after an exception?<p>Azeem,</p> <p>Thanks for your help.  It seemed that the debugger acted a little different after disabling &quot;Unwind call stack on unhandled exceptions&quot; option.  The Application just terminated when I clicked Continue on my AbortException.  Is it normal?  What can I do if I want it ignore this exception and behave like it is executed independently?  Because I really don't want to restart debugging each time when this exception thrown.  Thanks.</p> <p>Stanley</p>Thu, 23 Nov 2006 03:50:43 Z2006-11-23T03:50:43Zhttp://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/2ba45746-64b0-4ac7-98fe-268bd80ff939#30617e55-dbbc-459c-82d4-7c1d922967edhttp://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/2ba45746-64b0-4ac7-98fe-268bd80ff939#30617e55-dbbc-459c-82d4-7c1d922967edLifeng Lu - MSFThttp://social.msdn.microsoft.com/Profile/en-US/?user=Lifeng%20Lu%20-%20MSFTHow to continue execution after an exception?<p>Yes, it is expected.  The reason is the exception event handler is disabled, when you run it under debugger. That is by-design to help debugger to stop on unexpected exceptions. With the exception event handler, you would catch all exceptions, so you would miss a bug, if your code causes, for example, a NullReference exception.</p> <p>Of course, in your scenario, the exception is expected. Unfortunately, there is no way to disable this behavior (which is done in the framework code in your application.)  </p> <p>You can try to start your application in non-debug mode, (start it out of the Visual Studio), and attach the debugger to your application after this.  That will make the application to think there is no debugger attached when it starts, so your event handler could work.</p> <p>Thanks</p> <p> </p>Wed, 29 Nov 2006 21:52:10 Z2007-01-05T18:38:18Zhttp://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/2ba45746-64b0-4ac7-98fe-268bd80ff939#6e6bdf62-1ba9-4da6-acab-67a64233e542http://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/2ba45746-64b0-4ac7-98fe-268bd80ff939#6e6bdf62-1ba9-4da6-acab-67a64233e542Stanley Chou_http://social.msdn.microsoft.com/Profile/en-US/?user=Stanley%20Chou_How to continue execution after an exception?<p>Lifeng,</p> <p>Thanks for your help.  It works.</p> <p>Stanley</p>Wed, 03 Jan 2007 09:11:17 Z2007-01-03T09:11:17Z