Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8868001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:09:51+00:00 2026-06-14T17:09:51+00:00

I was using these two articles as a reference to implement IErrorHandler: ErrorHandler doesn’t

  • 0

I was using these two articles as a reference to implement IErrorHandler:

ErrorHandler doesn’t seem…

Roy Primrose’s blog post

(I’m using .net Framework 3.5.)

However, I am having a bit trouble – whenever I try to start the service, I get following error:

System.Configuration.ConfigurationErrorsException: Cannot add the behavior extension ‘errorHandlerExtension’ to the service behavior named ‘Test.TestService.Service1Behavior’ because the underlying behavior type does not implement the IServiceBehavior interface.

Here are my code and config files:

ErrorhandlerExtension.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel.Configuration;
using System.Configuration;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
using System.Collections.ObjectModel;

namespace Test.TestService
{
class ErrorHandlerExtension:BehaviorExtensionElement,IServiceBehavior
{
    public override Type BehaviorType
    {
        get { return typeof(ErrorHandler); }
    }
    protected override object CreateBehavior()
    {
        return new ErrorHandler();
    }
    void IServiceBehavior.AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters)
    {

    }
    private IErrorHandler GetInstance()
    {
        return new ErrorHandler();
    }
    void IServiceBehavior.ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
    {
        IErrorHandler errorHandlerInstance = GetInstance();
        foreach (ChannelDispatcher dispatcher in serviceHostBase.ChannelDispatchers)
        {
            dispatcher.ErrorHandlers.Add(errorHandlerInstance);
        }
    }

    void IServiceBehavior.Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
    {
        foreach (ServiceEndpoint endpoint in serviceDescription.Endpoints)
        {
            if (endpoint.Contract.Name.Equals("IMetadataExchange") &&
                endpoint.Contract.Namespace.Equals("http://schemas.microsoft.com/2006/04/mex"))
                continue;

            foreach (OperationDescription description in endpoint.Contract.Operations)
            {
                if (description.Faults.Count == 0)
                {
                    throw new InvalidOperationException("FaultContractAttribute not found on this method");
                }
            }
        }
    }

}

}

web.config:

<system.serviceModel>  
  <extensions>
      <behaviorExtensions>
        <add name="errorHandlerExtension"
          type="Test.TestService.ErrorHandlerExtension, Test.TestService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
      </behaviorExtensions>
    </extensions>

    <behaviors>
      <serviceBehaviors>
        <behavior name="Test.TestService.Service1Behavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <errorHandlerExtension />
       </behavior>
     </serviceBehaviors>
    </behaviors>
</system.serviceModel>

Whenever I get rid of the errorHandlerExtension / element, the service works fine, but it fails to start whenever I include errorHandlerExtension element (with the error). I’m new to WCF and quite stumped. Any ideas?

edit: added ErrorHandler.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
using System.Collections.ObjectModel;

namespace Test.TestService
{
public class ErrorHandler:IErrorHandler
{

    public bool HandleError(Exception error)
    {

        LogError("UnhandledError: "+ error);
        return true;
    }

    public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
    {
        FaultException faultException = new FaultException("Exception message:ProvideFault");
        MessageFault messageFault = faultException.CreateMessageFault();
        fault = Message.CreateMessage(version, messageFault, faultException.Action);
    }

}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:09:52+00:00Added an answer on June 14, 2026 at 5:09 pm

    Like I stated above, Implementing the IServiceBehavior in the ErrorHandler instead of ErrorHandlerExtension solved this problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using these two functions in order to rotate my objects in my
t = Time.now d = 10.minutes.from_now Using these two variables, how do I output
What is the difference between these two: font-style:italic font-style:oblique I tried using the W3Schools
I have two tables (using table variables for illustration. You can run these directly
I am using servlet there is two method redirect and forward both are send
Consider there are two wi-fk networks A & B using the same channel and
what does it mean where there are two id's in the jquery selector using
I am now quite comfortable using autosizing masks in IB but there are two
In Python lists, there are two alternative ways of performing a list sort: Using
I am using the .NET XmlSerializer class to deserialize GPX files. There are two

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.