Visual Studio has the ability to break all exceptions, even if they are caught. Note the checkbox in the Abandoned section for CLR exceptions. When it is checked, the debugger is divided into each statement throw, even if there is catchsomewhere in the call stack.

Is there a way to do this in code too? I am using .NET 4.5.1 in a 64bit class library. My goal is to log all exceptions and stack trace. Thus, when I test my program on computers that do not have Visual Studio, I get a log of thrown exceptions, even those that I process, showing a dialog to the user. My program has multithreading, so it will also need to create an event in the thrown exception in any thread.
One terrible way to do this is to simply extend Exception, put some code in this constructor of the new class and make sure that all exceptions extend it. But this is not feasible, given that many of the exceptions that are thrown are not even in my code, but in the CLR itself.
So, ideas on how to raise or listen to an event that occurs every time an exception is thrown, even if that exception is caught? All I saw were different ways of catching uncaught exceptions, which I don't want.
source
share