Problem adding a behaviors element to my WCF client config
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 complaini开发者_如何学Gong about the behaviorConfiguration attribute in the endpoint element.
Any ideas? .Net 4.0 BTW.
EDIT: I should also point out that this is in a WP7 project.
The WCF concept of behaviors doesn't exist in the Silverlight 4 (WP7) version of system.ServiceModel.
You'll need to specify the DataContractSerializer options elsewhere (either in another config section or in code)
Same goes for behaviorConfiguration on client/endpoint.
Reference this MSDN for the config description: http://msdn.microsoft.com/en-us/library/dd540827(v=vs.95).aspx
精彩评论