How do I create a global exception handler for a WCF Services?

You can create a WCF error-logger by implementing IErrorHandler and associating it with the service; typically (for logging) you would return false from HandleError (allowing other handlers to execute), and log the error either in HandleError (using the Exception) or in ProvideFault (using the ref Message fault).

I apply this handler by writing a custom behavior (inheriting from BehaviorBase), which (in ApplyDispatchBehavior) adds the error-handler to endpointDispatcher.ChannelDispatcher.ErrorHandlers if it isn’t already there.

The behavior can be applied via configuration.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)