none
MaxItemsInObjectGraph Exception only in XP, but no problem with win7 RRS feed

  • Question

  • hi, buddy

    I met a strange issue

    I build a WCF Server under windows server 2008 R2 under .Net 4

    and I built a WPF application under .Net 4 also.

    When I install the same client application on different PC...something shocked me:

    All the PC running on win7 and win2008 , and so on . running normally.

    But the PCs running in XP report issue as below:

    System.ServiceModel.CommunicationException: There was an error while trying to serialize parameterhttp://www.microsoft.com/performancepoint/scorecards:webPartContext. 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. '.  Please see InnerException for more details. ---> System.Runtime.Serialization.SerializationException: 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. 

    How can I solve it??

    Saturday, July 26, 2014 2:40 PM

Answers

  • Hi,
    >>System.ServiceModel.CommunicationException: There was an error while trying to serialize parameterhttp://www.microsoft.com/performancepoint/scorecards:webPartContext. 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. '.  Please see InnerException for more details. ---> System.Runtime.Serialization.SerializationException: 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. 

    When occurs the above problem, 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 <behavior> as part of a <dataContractSerializer> element.  Your service’s configuration might look like this:

    <system.serviceModel>   
            <behaviors>    
                <serviceBehaviors>    
                    <behavior name="DefaultBehavior" MaxItemsInObjectGraph="2147483647">    
                        <dataContractSerializer maxItemsInObjectGraph="2147483647" />     
                        <serviceMetadata httpGetEnabled="true" />    
                        <serviceDebug includeExceptionDetailInFaults="true" />    
                    </behavior>    
                </serviceBehaviors>    
            </behaviors>    
            <services>    
                <service behaviorConfiguration="DefaultBehavior" name="MyService">    
                    <endpoint address="" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_MyService" contract="IMyService">    
                        <identity>    
                            <dns value="localhost" />    
                        </identity>    
                    </endpoint>    
                    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />    
                </service>    
             </services>    
        </system.serviceModel>

    For the client, the configuration should look like this:

    <system.serviceModel>   
        <behaviors>    
        <endpointBehaviors>    
            <behavior name="ClientBehavior">    
                <dataContractSerializer maxItemsInObjectGraph="2147483647"/>     
            </behavior>    
        </endpointBehaviors>    
        </behaviors>
    
        <client>   
          <endpoint address=http://localhost/MyService.svc    
            binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_MyServiceConfiguration"    
            contract="ServiceReferences.IMyService" name="WSHttpBinding_MyService"     
            behaviorConfiguration="ClientBehavior">    
            <identity>    
              <dns value="localhost" />    
            </identity>    
          </endpoint>    
        </client>    
      </system.serviceModel>

    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.

    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.


    Monday, July 28, 2014 6:19 AM
    Moderator