Hi,
It is possible to hook on the UnhandledException event in the Default app
domain, and that way get notifications about unhandled exceptions in all of
the threads in the win32 process, i.e. all of the App Domains.
Is there a way to know in which AppDomain the exception occured?
Robert Aman - 03 Nov 2004 13:12 GMT
> Hi,
>
[quoted text clipped - 3 lines]
>
> Is there a way to know in which AppDomain the exception occured?
I don't really know if you can attach to events in other domains,
never tried, though I tend to doubt it, but I do know that you could
attach to the event in the same domain the error occurs and raise a
custom error flag of some sort on an object that extends
MarshalByRefObject which would be visible in the other AppDomain.
It's a neat idea, and if you don't mind, I'll probably steal it from
you. :-)
Bob Aman
http://www.rapidcanvas.com
Nadav - 12 Nov 2004 01:48 GMT
This could be done through Win32 API, use DllImport attribute in combination
with SetUnhandledExceptionFilter API, caching exception this way will enable
you to get notifications of system exception such as access violation that
the standart try -- cache dosn't intersept.
P.S.
Maybe there is a managed equivalent...
> > Hi,
> >
[quoted text clipped - 15 lines]
> Bob Aman
> http://www.rapidcanvas.com
David Levine - 12 Nov 2004 03:43 GMT
If you subscribe to the UnhandledException event in the default appdomain
you will get notifications when a UE occurs in any appdomain within that
process. In fact, subscribing to that event in the other appdomains will not
work because they never get called (a bug in the current framework).
However, none of these will get notified about a UE in a Win32 thread that
is outside the managed process. I'm not sure how you'd even do that in a
pure win32 app, let alone a managed app. It doesn't sound like that's what
you want to do, but your phrasing makes that unclear.
> Hi,
>
[quoted text clipped - 4 lines]
>
> Is there a way to know in which AppDomain the exception occured?
rlander [MSFT] - 15 Dec 2004 20:44 GMT
Yes, you can do this, just like you suggest ...
Here is a blog post that I did in response ....
http://hoser.lander.ca/PermaLink.aspx?guid=4d6820a1-c059-44bc-8b2e-84b2c6a61a39
thanks -- rich