Fixing MaxItemsInObjectGraph quota Error in WCF Service

Date Published: 28 April 2011

Fixing MaxItemsInObjectGraph quota Error in WCF Service

I have a WCF Service that occasionally yields a message like this one:

Maximum number of items that can be serialized or deserialized in an object graph is ‘65536’. Change the object graph or increase the MaxItemsInObjectGraph quota.

Today isn’t the first time I’ve run into this message – I’ve fixed this issue before – but since this is the 2nd or more time I’ve run into it, I thought I’d post a quick resolution here so I can find it again later myself, and perhaps help some others. There’s a rather long forum thread on this subject that ultimately includes the solution, but digging it out is a bit painful as is the case with so many forum threads, so I’ll sum up here and just give you what you need.

First, you need to realize that to resolve this issue you will need configuration elements to be specified on both the client and the server. In both cases, the configuration you are looking for is going to be in a named as part of a element. Your service’s configuration might look like this:



I notice that my specifies a MaxItemsInObjectGraph value but I don’t know that that is necessary. I’ve left it here since it’s what I actually have working in production, but the solution I found online only indicates the need for the dataContractSerializer maxItemsInObjectGraph (note case) value. For the client, the configuration should look like this:


<endpoint address=http://localhost/MyService.svc
binding="wsHttpBinding" bindingConfiguration="WSHttpBindingMyServiceConfiguration"
contract="ServiceReferences.IMyService" name="WSHttpBinding


Once you have these beautiful and extremely intuitive blocks of user-friendly XML in place, your WCF stuff should magically work again with larger than 65536 object graph sizes! Enjoy!

Steve Smith

About Ardalis

Software Architect

Steve is an experienced software architect and trainer, focusing on code quality and Domain-Driven Design with .NET.


Copyright © 2021