none
Try-Catch not catching exception RRS feed

  • Question

  • Hi

    A few days ago it used to work well. But now, I don't know what happened.

    Try/Catch DOES NOT CATCH the exception. The debbuger always stops the program execution and show the exception.

    Before this problem, when a Try/Catch statement exists, it handled the exception and when not exists the debbuger catch the exception, stop the program and show the problem.

    I've already tried with several Exceptions configuration in Debbug menu, but nothing good happens.

    Thanks.

    Thursday, April 18, 2013 2:41 PM

Answers

  • Hello,

    I would strongly suggest giving us more details no matter what direction you take as this will help us help you.

    If the exception is "catchable" then Catch of the Try-Catch will work as designed while if the exception is unrecoverable even by the base unhandled exception handler the Try-catch will not catch and give you an opportunity to work with it.

    You could implement my basic unhandled exception handler explained with code in the page below. You would compile/build the project then run it from Windows Explorer, not the IDE. Once the exception is thrown it will write information to a text file in the app folder which you could then report back here.

    http://code.msdn.microsoft.com/Dealing-with-unhandled-9b933818


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

    Thursday, April 18, 2013 5:01 PM
    Moderator

All replies

  • You first have to tell what the exception is. 

    Be aware the only exceptions which can be catched are those which are thrown. 


    Success
    Cor

    Thursday, April 18, 2013 2:49 PM
  • Leo,

    Can you show an example that doesn't work?

    What framework version is this?


    Please call me Frank :)

    Thursday, April 18, 2013 2:52 PM
  • Hello,

    I would strongly suggest giving us more details no matter what direction you take as this will help us help you.

    If the exception is "catchable" then Catch of the Try-Catch will work as designed while if the exception is unrecoverable even by the base unhandled exception handler the Try-catch will not catch and give you an opportunity to work with it.

    You could implement my basic unhandled exception handler explained with code in the page below. You would compile/build the project then run it from Windows Explorer, not the IDE. Once the exception is thrown it will write information to a text file in the app folder which you could then report back here.

    http://code.msdn.microsoft.com/Dealing-with-unhandled-9b933818


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

    Thursday, April 18, 2013 5:01 PM
    Moderator
  • Make sure that on the "Exceptions" dialog box, the specific exception being thrown is not configured to "Break when an exception is thrown".  When the flag is set to break when thrown it doesn't matter what you have in terms of try/catch - the debugger will break the execution and show the exception.

    As the others stated, more information would be helpful.
    Friday, April 19, 2013 12:07 PM
  • Make sure that on the "Exceptions" dialog box, the specific exception being thrown is not configured to "Break when an exception is thrown".  When the flag is set to break when thrown it doesn't matter what you have in terms of try/catch - the debugger will break the execution and show the exception.

    As the others stated, more information would be helpful.

    Steve,

    The OP wrote in his original message that he had done that.


    Success
    Cor

    Friday, April 19, 2013 12:29 PM