Setting custom WCF-binding behaviour via .config file - why doesn't this work?

Posted by Andrew Shepherd on Stack Overflow See other posts from Stack Overflow or by Andrew Shepherd
Published on 2010-05-30T23:24:26Z Indexed on 2010/05/31 0:52 UTC
Read the original article Hit count: 695

Filed under:
|
|

I am attempting to insert a custom behavior into my service client, following the example here.

I appear to be following all of the steps, but I am getting a ConfigurationErrorsException. Is there anyone more experienced than me who can spot what I'm doing wrong?

Here is the entire app.config file.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <behaviors>
            <endpointBehaviors>
                <behavior name="ClientLoggingEndpointBehaviour">
                    <myLoggerExtension />
                </behavior>
            </endpointBehaviors>
        </behaviors>
        <extensions>
            <behaviorExtensions>
                <add name="myLoggerExtension"
                     type="ChatClient.ClientLoggingEndpointBehaviourExtension, ChatClient, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"/>
            </behaviorExtensions>
        </extensions>
        <bindings>
        </bindings>
        <client>
            <endpoint
                behaviorConfiguration="ClientLoggingEndpointBehaviour"
                name="ChatRoomClientEndpoint"
                address="http://localhost:8016/ChatRoom"
                binding="wsDualHttpBinding"
                contract="ChatRoomLib.IChatRoom"
                />
        </client>
    </system.serviceModel>
</configuration>

Here is the exception message:

An error occurred creating the configuration section handler for system.serviceModel/behaviors: Extension element 'myLoggerExtension' cannot be added to this element. Verify that the extension is registered in the extension collection at system.serviceModel/extensions/behaviorExtensions. Parameter name: element (C:\Documents and Settings\Andrew Shepherd\My Documents\Visual Studio 2008\Projects\WcfPractice\ChatClient\bin\Debug\ChatClient.vshost.exe.config line 5)

I know that I've correctly written the reference to the ClientLoggingEndpointBehaviourExtensionobject, because through the debugger I can see it being instantiated.

© Stack Overflow or respective owner

Related posts about wcf

Related posts about wcf-binding