Generic operation error handling with OperationInvoker
WCF provides a built-in interface called IErrorHandler
for handling exceptions occurring within the WCF service operations processing pipeline. By using the IErrorHandler
interface, you can capture those unhandled exceptions during service operation execution and return a customized FaultException
object to the client.
However, if you feel IErrorHandler
is not flexible or powerful enough, you can consider creating your own generic error-handling component, which can handle the exceptions occurring during the execution of certain WCF operations at the server side. In this recipe, we will demonstrate how to use the IOperationInvoker
extension point to implement a custom operation error-handling component.
How to do it...
In the sample service, we will create a custom OperationInvoker
and use it to intercept exceptions in each service operation call and log the exceptions into the Windows Event Log system.
Implement a custom
OperationInvoker...