Microsoft Developer Network > 포럼 홈 > Visual Studio Debugger > How to continue execution after an exception?
질문하기질문하기
 

답변됨How to continue execution after an exception?

  • 2006년 11월 22일 수요일 오전 7:18Stanley Chou_ 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     

    hi,

    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 "silent exception".  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 http://msdn2.microsoft.com/en-us/library/ky9bw27e.aspx but it didn't help...

    Thanks.

    Stanley

답변

  • 2006년 11월 29일 수요일 오후 9:52Lifeng Lu - MSFT중재자사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨

    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.

    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.) 

    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.

    Thanks

     

모든 응답

  • 2006년 11월 22일 수요일 오후 6:32Azeem Khan - MSFTMSFT, 중재자사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     

    Stanley,

    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 -> Options -> Debugging -> General -> Unwind callstack on unhandled exception or you can disable Exception Assistant itself. This should let you continue from unhandled exceptions.

    If you have stopping on first-chance exceptions enabled (see Debug -> 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.

    Azeem Khan

    Visual Studio Debugger.

  • 2006년 11월 23일 목요일 오전 3:50Stanley Chou_ 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     

    Azeem,

    Thanks for your help.  It seemed that the debugger acted a little different after disabling "Unwind call stack on unhandled exceptions" 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.

    Stanley

  • 2006년 11월 29일 수요일 오후 9:52Lifeng Lu - MSFT중재자사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨

    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.

    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.) 

    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.

    Thanks

     

  • 2007년 1월 3일 수요일 오전 9:11Stanley Chou_ 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     

    Lifeng,

    Thanks for your help.  It works.

    Stanley