MaxItemsInObjectGraph – WCF RIA Services Exception


The MaxItemsInObjectGraph error message comes up fairly often in the WCF RIA Services forums and I just ran into it on a personal project so I thought I’d write a quick blog on how to fix this error.

The exact error message from WCF Trace is:

'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. '.

You need to add the following code to your web.config, and replace the following:

HockeyStatsService-Web-HockeyStatsDomainService with YourRiaProjectName-Web-YourDomainServiceName

HockeyStatsService.Web.HockeyStatsDomainService with YourRiaProjectName.Web.YourDomainServiceName

  <service name="HockeyStatsService.Web.HockeyStatsDomainService"
    <behavior name="HockeyStatsService-Web-HockeyStatsDomainService">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <dataContractSerializer maxItemsInObjectGraph="655360"/>