Avoid lengthy processing such as logging in IErrorHandler.ProvideFault( ).
With both service classes and callback classes, set IncludeExceptionDetailInFaults to true in debug sessions, either in the config file or programmatically:
public class DebugHelper { public const bool IncludeExceptionDetailInFaults = #if DEBUG true; #else false; #endif } [ServiceBehavior(IncludeExceptionDetailInFaults = DebugHelper.IncludeExceptionDetailInFaults)] class MyService : IMyContract {...}
In release builds, do not return unknown exceptions as faults except in diagnostic scenarios.
Consider using the ErrorHandlerBehaviorAttribute on the service for both promoting exceptions to fault contracts and automatic error logging:
[ErrorHandlerBehavior] class MyService : IMyContract {...}
Consider using the CallbackErrorHandlerBehaviorAttribute on the callback client for both promoting exceptions to fault contracts and automatic error logging:
[CallbackErrorHandlerBehavior(typeof(MyClient))] public partial class MyClient : IMyContractCallback { public void OnCallabck( ) {...} }