Problem adding a behaviors element to my WCF client config

Posted by SteveChadbourne on Stack Overflow See other posts from Stack Overflow or by SteveChadbourne
Published on 2011-02-24T23:22:37Z Indexed on 2011/02/24 23:25 UTC
Read the original article Hit count: 253

Filed under:
|
|

I'm trying to add a behaviors element to my client config file so I can specify maxItemsInObjectGraph.

The error I get is: The element 'system.serviceModel' has invalid child element 'behaviors'. List of possible elements expected: 'bindings, client, extensions'.

Here is my config:

<configuration>

  <system.serviceModel>

    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_KernService" 
          maxBufferSize="2147483647"
          maxReceivedMessageSize="2147483647">
          <security mode="None" />
        </binding>
      </basicHttpBinding>
    </bindings>

    <behaviors>
      <endpointBehaviors>
        <behavior name="ServiceViewEventBehavior">
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
      </endpointBehaviors>
    </behaviors>

    <client>
      <endpoint address="http://localhost/KernMobile.WCF/KernService.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_KernService"
        contract="KernWcfService.KernService" name="BasicHttpBinding_KernService"
        behaviorConfiguration="ServiceViewEventBehavior" />
    </client>

  </system.serviceModel>

</configuration>

It's also complaining about the behaviorConfiguration attribute in the endpoint element.

Any ideas? .Net 4.0 BTW.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about wcf