CRM 2011 : RetrieveAllColumns all rows ::: The maximum message size quota for incoming messages (524288) has been exceeded. To increase the quota, use the MaxReceivedMessageSize

To solve the above issue while retrieving all columns, all rows in CRM 2011, if you are using pure OrganizationServiceClient object, you can try either modifying in the app.config file OR using a line of code.

1. Increase the “maxReceivedMessageSize” and “maxBufferSize” in the app.config file to some large integer values such as “2147483647”. Note that both values should be same.

<httpTransport maxReceivedMessageSize=2147483647maxBufferSize=2147483647..“”>

2. Now, you can either use app.config change or use one line of code :

 

App.Config file change: add below section inside <system.serviceModel> section in your app.config file <behaviors><endpointBehaviors><behaviorname=ClientBehavior><dataContractSerializer maxItemsInObjectGraph=2147483647/></behavior></endpointBehaviors></behaviors>

 Then add the behaviorConfiguration=”ClientBehavior” in <client> section in the same config file as shown below. Here name of the behaviourConfiguration “ClientBehaviour” is the same as we have added above.

<client><endpointaddress=http://../XRMServices/2011/Organization.svcbinding=..bindingConfiguration=..contract=name=behaviorConfiguration=ClientBehavior>

 

Use of code: Use the below line of code before RetrieveMulitple line.

(OrganizationServiceClient object).Endpoint.Contract.Operations.Find(“RetrieveMultiple”).Behaviors.Find<System.ServiceModel.Description.DataContractSerializerOperationBehavior>().MaxItemsInObjectGraph = int.MaxValue;

 

 Thats it. It will let you have upto 20 Mb of data with the paging of 5000 rows depending on size at one CRM call.

Reference : http://msdn.microsoft.com/en-us/library/system.runtime.serialization.datacontractserializer.maxitemsinobjectgraph.aspx

regards

joon

Advertisements