none
WCF- MaxItemsInObjectGraph has no effect whatsoever RRS feed

  • Question

  • I have two wcf services, where one service (say S1 - hosted in IIS) consume the other service (say S2 - host in windows service). Due to recent size change in response from S2, I end-up in revising the MaxItemsInObjectGraph value both in S1 and S2 to hold large response data. I tried revising value through code, did it through service contact attribute ( service implementation) and even through config. Noething seems working and still I am getting following exception

    The InnerException message was '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.

    **Client config**

        <client>
         <endpoint behaviorConfiguration="REngineEndPointBehavior" address="net.tcp://nor-nexdev-02:8005/REngineService"
                binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IR"
                contract="REngineService.IR" name="NetTcpBinding_IR" />
        </client>
        <behaviors>
        <endpointBehaviors>
          <behavior name="REngineEndPointBehavior" MaxItemsInObjectGraph="2147483647">
         <dataContractSerializer maxItemsInObjectGraph="2147483647" />
          </behavior>
        </endpointBehaviors>
              <serviceBehaviors>
                <behavior name="NServiceBehavior">
        ...        </behavior>        
              </serviceBehaviors>
            </behaviors>
            <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
          </system.serviceModel>
         

    **Server config**

     

        <services>
         <service name="Engine.R"
                       behaviorConfiguration="REngineServiceBehavior">
                <host>
                  <baseAddresses>
                    <add baseAddress="net.tcp://xxxxxxxxx:8005/REngineService"/>
                  </baseAddresses>
                </host>
                <endpoint address="" binding="netTcpBinding" bindingConfiguration="netTcp" contract="Engine.IR" />
                <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
              </service>
            </services>
            <behaviors>
              <serviceBehaviors>
                <behavior name="REngineServiceBehavior" MaxItemsInObjectGraph="2147483647">
         <dataContractSerializer maxItemsInObjectGraph="2147483647" />
                  <serviceMetadata httpGetEnabled="false"/>
                  <serviceDebug includeExceptionDetailInFaults="true"/>  
                  <serviceThrottling maxConcurrentSessions="1000"/>
                </behavior>
              </serviceBehaviors>
            </behaviors>
          </system.serviceModel>


    If this post answers your question, please click Mark As Answer. If this post is helpful please click Mark as Helpful.

    Regards,
    Nair S

    Wednesday, April 1, 2015 3:39 PM

Answers

  • Hi,

    For this scenario, 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. Please try to check the following article to see if you have missed something:

    http://blog.aggregatedintelligence.com/2011/01/wcf-maxitemsinobjectgraph-error.html .

    Besides, please also increase the timeout value to see if it works.

    In WCF we can use the wcf trace to help narrow down this issue.
    #How to enable the WCF Trace:
    https://msdn.microsoft.com/en-us/library/ms733025(v=vs.110).aspx ,

    Regards.



    Thursday, April 2, 2015 8:28 AM
    Moderator
  • Hi Nair S,

    Based on your config file, I see that you have already configured the client and service side to increase the MaxItemsInObjectGraph value, please try to increase the maxReceivedMessageSize/maxBufferSize/maxBufferPoolSize of the netTcpBinding as well in both the client and service side to see if it works:

    <netTcpBinding>
      <binding name="MynetTcpBinding" closeTimeout="00:10:00"
        openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
        allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
        maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
        messageEncoding="Text" textEncoding="utf-8" transferMode="Streamed"
        useDefaultWebProxy="true">
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
          maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        <security mode="None"/>
      </binding>
    </netTcpBinding>
    Best Regards,
    Amy Peng

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Tuesday, April 14, 2015 2:04 AM
    Moderator

All replies

  • Hi,

    For this scenario, 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. Please try to check the following article to see if you have missed something:

    http://blog.aggregatedintelligence.com/2011/01/wcf-maxitemsinobjectgraph-error.html .

    Besides, please also increase the timeout value to see if it works.

    In WCF we can use the wcf trace to help narrow down this issue.
    #How to enable the WCF Trace:
    https://msdn.microsoft.com/en-us/library/ms733025(v=vs.110).aspx ,

    Regards.



    Thursday, April 2, 2015 8:28 AM
    Moderator
  • Hi Nair S,

    Based on your config file, I see that you have already configured the client and service side to increase the MaxItemsInObjectGraph value, please try to increase the maxReceivedMessageSize/maxBufferSize/maxBufferPoolSize of the netTcpBinding as well in both the client and service side to see if it works:

    <netTcpBinding>
      <binding name="MynetTcpBinding" closeTimeout="00:10:00"
        openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
        allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
        maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
        messageEncoding="Text" textEncoding="utf-8" transferMode="Streamed"
        useDefaultWebProxy="true">
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
          maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        <security mode="None"/>
      </binding>
    </netTcpBinding>
    Best Regards,
    Amy Peng

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Tuesday, April 14, 2015 2:04 AM
    Moderator