views:

74

answers:

5

I handled the same exception in two programs, but I got the different results. I don't know why.

the first result is the one the program unable to caught

Scapshot1:      www.freeimagehosting.net/uploads/e2b37433a3.png

and the second is the one the program succeed to caught

Scapshot2:      www.freeimagehosting.net/uploads/6ab7564999.png

Why I got such a different?

+2  A: 

Well, you haven't really provided much context. Things to check:

  • Are they the same type of application (WPF, WinForms, Silverlight, Console etc)?
  • Are they using the same version of .NET?
  • Are they running on the same version of Windows?
  • Do they have the same code for reacting to unhandled exceptions?
Jon Skeet
oops. It raise an exception in my catch block again
Restart
+3  A: 

From what I can see, in #1 you are running in the debugger. In #2 you are not.

In fact, I will assume the exception is exactly the same, as the message is the same. There is no difference, IOW.

leppie
Yup. Same error
Dark Star1
+1  A: 

I am not sure if I understand, it looks like it's the same erro but

  • pic1 - unhandled error
  • pic2 - handled error

please provide more information

tom3k
+1  A: 

The behaviour of the debugger in the face of exceptions can vary wildly.

Exception Handling (Debugging)

Damien_The_Unbeliever
+1  A: 

You cannot change Application.UnhandledExceptionMode after Application.Run() was called, so clearly that's not the one that's going to catch the exception.

Which leaves AppDomain.UnhandledException. Yes, the debugger will break on the exception before that event is raised. Nice feature, allows you to debug the exception reason. Just press F5 to continue execution to trigger the event handler. There's no evidence of you using the debugger in the 2nd screen shot, looks like you started it with Ctrl+F5.

Hans Passant