Задайте вопросЗадайте вопрос
 

ОтвеченоHow to continue execution after an exception?

Ответы

  • 29 ноября 2006 г. 21: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

     

Все ответы

  • 22 ноября 2006 г. 18: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.

  • 23 ноября 2006 г. 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

  • 29 ноября 2006 г. 21: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

     

  • 3 января 2007 г. 9:11Stanley Chou_ Медали пользователяМедали пользователяМедали пользователяМедали пользователяМедали пользователя
     

    Lifeng,

    Thanks for your help.  It works.

    Stanley