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

    Question

  • I am using Using  WCF REST service template 40 and Silverlight as Client application but I keep getting the '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.' Error the relevant part of my web.config is givven below. I have been scanning the forums and have tried many things but nothing is working. Please share if any one have some solution.

    <system.serviceModel>
    
          <behaviors>
    			<serviceBehaviors>
    				<behavior name="Default">
    					<serviceMetadata httpGetEnabled="false" />
    					<serviceDebug includeExceptionDetailInFaults="true" />
    					<serviceTimeouts transactionTimeout="00:55:00" />
              <dataContractSerializer maxItemsInObjectGraph="2000000"/>
              
    				</behavior>
    			</serviceBehaviors>
    			<endpointBehaviors>
    				<behavior name="REST">
              <dataContractSerializer maxItemsInObjectGraph ="2000000"/>
    
              <webHttp />
    				</behavior>
    			</endpointBehaviors>
    
    		</behaviors>
    	</system.serviceModel>
    	<system.webServer>
    		<modules runAllManagedModulesForAllRequests="true">
    			<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    		</modules>
    	</system.webServer>
    	<system.serviceModel>
    		<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    		<standardEndpoints>
    			<webHttpEndpoint>
    				<!-- 
                Configure the WCF REST service base address via the global.asax.cs file and the default endpoint 
                via the attributes on the <standardEndpoint> element below
            -->
    				<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" defaultOutgoingResponseFormat="Json" maxReceivedMessageSize="10485760" maxBufferPoolSize="10485760" maxBufferSize="10485760">
    					<readerQuotas maxDepth="32" maxStringContentLength="10485760" maxArrayLength="10485760" maxBytesPerRead="10485760" />
    					<security mode="None" />
    				</standardEndpoint>
    			</webHttpEndpoint>
    		</standardEndpoints>
    	</system.serviceModel>
    

    Friday, March 16, 2012 6:40 AM

Answers

  • Sorry for that infinite delay.

    The problem was solved by adding [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, MaxItemsInObjectGraph = Int32.MaxValue)] to the service class.


    Rajat Saini

    • Marked as answer by Rajat Saini Tuesday, June 05, 2012 5:05 AM
    Tuesday, June 05, 2012 5:04 AM

All replies

  • Post this to WCF Forum for better response.

    Welcome to MSDN Forums. Feel free to ask your questions and Please Note to Vote helpful topics and Mark answering posts. Sudhakar

    Wednesday, March 28, 2012 5:37 AM
  • Sorry for that infinite delay.

    The problem was solved by adding [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, MaxItemsInObjectGraph = Int32.MaxValue)] to the service class.


    Rajat Saini

    • Marked as answer by Rajat Saini Tuesday, June 05, 2012 5:05 AM
    Tuesday, June 05, 2012 5:04 AM