UnhandledExceptionHandler delegate not working in remoting host

From: Ian Tompsett (anonymous_at_discussions.microsoft.com)
Date: 02/10/04


Date: Mon, 9 Feb 2004 21:46:07 -0800

Hi

I'm trying to use AppDomain's UnhandledExceptionEventHandler in my remoting host console app. The console app is very simple - it just loads a remoting configuration file and then sits there allowing requests to go through to various remotable classes in some other assemblies that it references. This all seems to work happily.

But I'd like to catch any unhandled exceptions that occur in any of the actual assemblies being used by client applications (so I can log them and then throw them again for consumption in the client apps).

So just before the call to RemotingConfiguration.Configure, I've added a delegate to handle
AppDomain.CurrentDomain.UnhandledException. I've then forced an exception to occur in one of the assemblies. This exception is being raised - it's getting back to the client application - but my UnhandledException delegate isn't being called.

Is there something else I should do? I've put the code below...

Thanks

//By the way, does it matter if I add the STAThread attribute or not?
[STAThread]
static void Main(string[] args)
{
        AppDomain currDomain = AppDomain.CurrentDomain;
        currDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
        RemotingConfiguration.Configure ("RemoteHost.exe.config");
        Console.WriteLine ("Press Enter to terminate...");
        Console.ReadLine ();
}
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
        Console.WriteLine("Exception occurred");
}



Relevant Pages

  • Re: Can RCW and CCW be used together?
    ... code that you show seems to be VB6 code, but the exception must be thrown ... component project reference to my client project and build. ... problem-domain specific assemblies and the assemblies for the RCW-Interop ...
    (microsoft.public.dotnet.framework.interop)
  • Re: Remoting, AppDomains, and Exceptions
    ... > 2) Be sure to catch all exceptions coming from the second AppDomain and, ... > InnerException), raise a new exception and copy the message over. ... >> independant assemblies which expose methods to the client. ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: Custom exception and JIT debugging
    ... That implies that you may be seeing an artifact of the environment, ... the assemblies are located may be different. ... client code that catches the exception. ... If the type used in the client is defined in an assembly ...
    (microsoft.public.dotnet.framework)
  • .Net Remoting and Exceptions
    ... I've got a Windows Service farming out assemblies to client ... a whopping great "Missing Assembly" Exception back on the client. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Client Firewall and Outlook
    ... Additionally there are times when a user is on the phone to a client, ... I am trying to add Outlook ... as an exception to the firewall list. ... on windows firewall in control panel. ...
    (microsoft.public.windows.server.sbs)