Search code examples
c#error-handlingremoting

How to catch unhandled exceptions when using .NET Remoting


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?


Solution

  • 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.