I wanted to set some handler for all the unexpected exceptions that I might not have caught inside my code. In Program.Main()
I used the following code:
AppDomain.CurrentDomain.UnhandledException
+= new UnhandledExceptionEventHandler(ErrorHandler.HandleException);
But it didn't work as I expected. When I started the application in debugging mode and threw an exception it did call the handler, but afterwards the exception helper in Visual Studio popped up as if the exception occurred without any handling. I tried Application.Exit() inside the handler but it didn't work as well.
What I would like to achieve is that the exception is handled with my handler and then the application closes nicely. Is there any other way to do it or am I using the code above in the wrong way?
question from:
https://stackoverflow.com/questions/406385/handling-unhandled-exceptions-problem 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…