Why Do I Receive a MaxItemsInObjectGraph Error in a Windows Service Environment?

Prerequisites

Symptoms

In an AgilePoint Windows Service environment, when AgilePoint Server returns a large amount of data - for example, large number of registered users - the following error appears:

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.

Cause

This error occurs when the number of current items exceeds the maximum limit of number of items that can be serialized or deserialized in an object graph.

Resolution

To resolve the issue, make the changes in the configuration files for both the server and the client:

  1. Back up the AgilePoint Server configuration file, [AgilePoint Server installation folder]\bin\Ascentn.AgilePoint.WCFService.exe.config.
  2. In a text editor, open the file Ascentn.AgilePoint.WCFService.exe.config.
  3. In the <system.serviceModel> node, add <dataContractSerializer>, as follows:
    <dataContractSerializer maxItemsInObjectGraph="2147483646" />

    The following example displays a portion of the Ascentn.AgilePoint.WCFService.exe.config file:

    <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior name="AgilePointServiceBehavior">
              <!-- To avoid disclosing metadata information, 
                       set the value below to false and remove the metadata 
                       endpoint above before deployment -->
              <serviceMetadata httpGetEnabled="true" />
              <!-- To receive exception details in faults for debugging 
                      purposes, set the value below to true.  Set to false 
                      before deployment to avoid disclosing exception 
                      information -->
              <serviceDebug includeExceptionDetailInFaults="true" />
            <dataContractSerializer maxItemsInObjectGraph="2147483646" />
            </behavior>
  4. Save Ascentn.AgilePoint.WCFService.exe.config.
  5. Back up the web.config for the client where the error occurs -- for example, Enterprise Manager or SharePoint.
  6. In a text editor, open the web.config file.
  7. In the <system.serviceModel> node, add the following code:
    <behaviors>
          <endpointBehaviors>
            <behavior name="Behaviors.ClientBehavior">
              <dataContractSerializer maxItemsInObjectGraph="2147483646" />
            </behavior>
          </endpointBehaviors>
    </behaviors>

    The following example displays a portion of the Enterprise Manager web.config file:

    <system.serviceModel>
        <behaviors>
          <endpointBehaviors>
            <behavior name="Behaviors.ClientBehavior">
              <dataContractSerializer maxItemsInObjectGraph="2147483646" />
            </behavior>
          </endpointBehaviors>
        </behaviors>
  8. For each endpoint declaration, in the <client> node, add the behaviorConfiguration attribute.
    behaviorConfiguration="Behaviors.ClientBehavior"

    The following example displays a portion of the Enterprise Manager web.config file:

    <endpoint address="http://demo3:80/AgilePointServer/Workflow" 
        binding="wsHttpBinding" behaviorConfiguration="Behaviors.ClientBehavior" 
        bindingConfiguration="WSHttpBinding_IWCFWorkflowService" contract="WorkflowService.IWCFWorkflowService" 
        name="WSHttpBinding_IWCFWorkflowService">
    
  9. Save the web.config file.

More Information