error handling across app domains

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

Say I have two app domains, Domain A and Domain B, that I do not want to
pass object references between. Domain A has Assembly A loaded, which
contains a type that inherits from exception. I want to more or less to pass
this exception to Domain B without loading Assembly A in it. I can do this
by passing some strings and then re-throwing an exception, but this seemed
kind of crude. I was thinking of using a serialization helper class, but was
wondering if one wasn't already built in. Or is that overkill? How is this
typically done?

TIA,
Bob
 
Bob,
Have you looked at the AppDomain.UnhandledException?

I have not used it in multiple AppDomain situations, however reading the
help for the above event it sounds like you just need to set a handler in
your startup AppDomain, then any unhandled exception in any app domain will
be handled by this handler...

For an unhandled exception:
Depending on the type of application you are creating, .NET has three
different global exception handlers.

For ASP.NET look at:
System.Web.HttpApplication.Error event
Normally placed in your Global.asax file.

For console applications look at:
System.AppDomain.UnhandledException event
Use AddHandler in your Sub Main.

For Windows Forms look at:
System.Windows.Forms.Application.ThreadException event
Use AddHandler in your Sub Main.

Hope this helps
Jay
 
I'll have a look at that, thanks.

Bob

Jay B. Harlow said:
Bob,
Have you looked at the AppDomain.UnhandledException?

I have not used it in multiple AppDomain situations, however reading the
help for the above event it sounds like you just need to set a handler in
your startup AppDomain, then any unhandled exception in any app domain will
be handled by this handler...

For an unhandled exception:
Depending on the type of application you are creating, .NET has three
different global exception handlers.

For ASP.NET look at:
System.Web.HttpApplication.Error event
Normally placed in your Global.asax file.

For console applications look at:
System.AppDomain.UnhandledException event
Use AddHandler in your Sub Main.

For Windows Forms look at:
System.Windows.Forms.Application.ThreadException event
Use AddHandler in your Sub Main.

Hope this helps
Jay
 
Back
Top