Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Catch Exceptions handled by External Assembly

Is it possible to catch Exceptions that are handled by an external (legacy) Assembly?

I don't think I can catch those exceptions since they are already handled, but similarly to Visual Studio "break on all exceptions" I thought that maybe I could at least get some notification about the exception.

e.g.: MyProduct.exe calls Utils.dll and Utils.dll is swallowing all exceptions, and doesn't return any information if something wrong happened.

PS: Modifying that external assembly is obviously an alternative, but it's very hard because it's actually spread across hundreds of customized copies

like image 509
drizin Avatar asked Dec 31 '25 23:12

drizin


1 Answers

You can subscribe to the AppDomain.FirstChanceException event to get notified of exceptions:

This event is only a notification. Handling this event does not handle the exception or affect subsequent exception handling in any way. After the event has been raised and event handlers have been invoked, the common language runtime (CLR) begins to search for a handler for the exception. FirstChanceException provides the application domain with a first chance to examine any managed exception.

like image 51
stuartd Avatar answered Jan 02 '26 12:01

stuartd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!