My C# code is being run through COM from unmanaged code (which happens to be VB6). Mainly for debugging & logging purposes I would like to catch any C# exceptions before they make their way back to the unmanaged code.
In comparison, for other "subsystems" like Winforms and WPF it is possible to do something like this - both of those offer an event that you can use to handle exceptions as you see fit. I guess in those instances your application code is being executed from those subsystems as a starting point, so that provides the 'hook' where the exceptions can be caught and corresponding events raised.
I'm looking for something similar (if it exists) from the COM interop "subsystem".
This answer mentions:
The CLR installs a catch-all exception handler in its interop layer
Does the mentioned "interop layer" makes accessible any event like this? Or some other mechanism to act on an exception before it heads to the unmanaged code?
Note - I don't see anything for COM mentioned in this very well regarded answer, so maybe that indicates this is not possible.
question from:
https://stackoverflow.com/questions/65849088/globally-catch-exceptions-before-returning-control-to-com-client 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…