public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
        {
            IErrorHandler errorHandler = null;

              try
              {
            errorHandler = new UnhandledExceptionsLoggingErrorHandler();
              }
              catch (MissingMethodException e)
              {
            throw new ArgumentException(
              "The errorHandlerType specified in the ErrorHandlerBehaviorAttribute constructor must have a public empty constructor.",
              e);
              }
              catch (InvalidCastException e)
              {
            throw new ArgumentException(
              "The errorHandlerType specified in the ErrorHandlerBehaviorAttribute constructor must implement System.ServiceModel.Dispatcher.IErrorHandler.",
              e);
              }
              catch (Exception exc)
              {
            _log.ErrorIfEnabled(() => "Unhandled exception while applying dispatch behavior.", exc);
              }

              foreach (ChannelDispatcher channelDispatcher in serviceHostBase.ChannelDispatchers.OfType<ChannelDispatcher>())
              {
            channelDispatcher.ErrorHandlers.Add(errorHandler);
              }
        }
        public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
        {
            IErrorHandler errorHandler = null;

            try
            {
                errorHandler = new UnhandledExceptionsLoggingErrorHandler();
            }
            catch (MissingMethodException e)
            {
                throw new ArgumentException(
                          "The errorHandlerType specified in the ErrorHandlerBehaviorAttribute constructor must have a public empty constructor.",
                          e);
            }
            catch (InvalidCastException e)
            {
                throw new ArgumentException(
                          "The errorHandlerType specified in the ErrorHandlerBehaviorAttribute constructor must implement System.ServiceModel.Dispatcher.IErrorHandler.",
                          e);
            }
            catch (Exception exc)
            {
                _log.ErrorIfEnabled(() => "Unhandled exception while applying dispatch behavior.", exc);
            }

            foreach (ChannelDispatcher channelDispatcher in serviceHostBase.ChannelDispatchers.OfType <ChannelDispatcher>())
            {
                channelDispatcher.ErrorHandlers.Add(errorHandler);
            }
        }