public void ApplyDispatchBehavior(ServiceDescription description, ServiceHostBase serviceHostBase) { var handler = (IErrorHandler)Activator.CreateInstance(_errorHandlerType);
foreach (ChannelDispatcherBase dispatcherBase in serviceHostBase.ChannelDispatchers) { var channelDispatcher = dispatcherBase as ChannelDispatcher; if (channelDispatcher != null) channelDispatcher.ErrorHandlers.Add(handler); } }
#endregion }
//来源:C/S框架网(www.csframework.com) QQ:1980854898
使用:
C# Code:
[ServiceBehavior(IncludeExceptionDetailInFaults = true)] [WCF_ExceptionBehaviour(typeof(WCF_ExceptionHandler))] public class AccountModuleService : IAccountModuleService {