nickd
nickd

Reputation: 4021

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?

Upvotes: 1

Views: 2101

Answers (2)

nickd
nickd

Reputation: 4021

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.

Upvotes: 0

Guy Starbuck
Guy Starbuck

Reputation: 21873

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.

Upvotes: 1

Related Questions