B
Bob Altman
I've written a DLL in "interop" mode (compiled with /clr). This DLL is a
wrapper for a managed library. It exposes native C-style entry points, calls
into the managed library, and marshals the results (if any) back to the native
caller.
Here's the short version of the question: Is there an easy way for my library
to catch unhandled managed exceptions (short of putting a try/catch block around
each top-level routine in my library)? As I explain below, I tried wiring up
the AppDomain.CurrentDomain.UnhandledException event, but that didn't work.
Here's the longer story:
If the managed code called by my library throws an exception that is ultimately
unhandled then my library's caller dies a horrible death. That horrible death
includes a dialog box that basically tells the user that the program died, but
offers little by way of useful information about unhandled exception (like the
exception name and the call stack). I want to display my own custom dialog in
response to an unhandled exception (before I kill the caller).
I have an existing class called UnhandledExceptionHandler in a managed library
(authored in VB) whose constructor wires up the
AppDomain.CurrentDomain.UnhandledException event. That class decodes the
unahandled exception and puts up a custom dialog.
I tried constructing an instance of my UnhandledExceptionHandler class in my
wrapper library, but it dies a horrible death. I'm just assuming (with no
really good evidence to support it) that /clr doesn't give me enough AppDomain
context to do this sort of thing.
TIA - Bob
wrapper for a managed library. It exposes native C-style entry points, calls
into the managed library, and marshals the results (if any) back to the native
caller.
Here's the short version of the question: Is there an easy way for my library
to catch unhandled managed exceptions (short of putting a try/catch block around
each top-level routine in my library)? As I explain below, I tried wiring up
the AppDomain.CurrentDomain.UnhandledException event, but that didn't work.
Here's the longer story:
If the managed code called by my library throws an exception that is ultimately
unhandled then my library's caller dies a horrible death. That horrible death
includes a dialog box that basically tells the user that the program died, but
offers little by way of useful information about unhandled exception (like the
exception name and the call stack). I want to display my own custom dialog in
response to an unhandled exception (before I kill the caller).
I have an existing class called UnhandledExceptionHandler in a managed library
(authored in VB) whose constructor wires up the
AppDomain.CurrentDomain.UnhandledException event. That class decodes the
unahandled exception and puts up a custom dialog.
I tried constructing an instance of my UnhandledExceptionHandler class in my
wrapper library, but it dies a horrible death. I'm just assuming (with no
really good evidence to support it) that /clr doesn't give me enough AppDomain
context to do this sort of thing.
TIA - Bob