views:

700

answers:

3

I want to catch all unhandled exceptions thrown in a remote object on the server and log them there before I translate them into some custom exception so that specific exceptions do not cross the client/server boundary.

I think I have to use a custom channel sync, but can anyone confirm this and/or have any other advice to give?

+1  A: 

I would use the Microsoft Enterprise Library Exception Handling app block -- it lets you handle errors and convert specific types of exception to a different type of exception before rethrowing to the client.

Guy Starbuck
A: 

@Guy: Thanks, I hadn't heard of this. I don't think it addresses my issue though as I want to catch unhandled exceptions. It seems to me that the EHAB is about applying a policy for coded exception handlers.

I just want to log the unexpected exceptions so we can code the appropriate handlers in later code versions.

nickd
A: 

After finding Eliyahu Baker's helpful blog post and reading chapter 12 of Rammer's Advanced .NET Remoting I wrote a custom channel sink that does what I want. This intercepts any exception and logs it locally before sending it on to the client.

Ideally, I'd like to log the exception and raise a more generic one for the client, but I haven't cracked that nut yet.

nickd