Add to the config
<behaviors>
<endpointBehaviors>
<behavior name="Behaviors.EndpointBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
</behaviors
Then define your client with behavior
<client>
<endpoint address=http://localhost:9997/Services/MyService
behaviorConfiguration="Behaviors.EndpointBehavior"
binding="wsHttpBinding" bindingConfiguration="WSHTTPBinding.Configuration.Client"
contract="IAppointments" name="Client.EndpointConfiguration" />
</client>
Or do it in code behind
foreach ( var operation in channelFactory.Endpoint.Contract.Operations )
{
var behavior = operation.Behaviors.Find() as DataContractSerializerOperationBehavior;
if ( behavior != null )
{
behavior.MaxItemsInObjectGraph = 2147483647;
}
}
(Source: http://devlicio.us/blogs/derik_whittaker/archive/2010/05/04/setting-maxitemsinobjectgraph-for-wcf-there-has-to-be-a-better-way.aspx)
I think you have to decorate the server side definition and the client endpoint as well.