ARDaniyal
ARDaniyal

Reputation: 159

Exception in returning Generic List from WCF

Hi I am stuck in strange issue,

I have an Generic list List<Accounts> it is populated from database, then this list is returning to client.

When list contains more than 3000 items it is throwing exception.

I have set following values in web.config

maxDepth="2147483647" 
maxStringContentLength="2147483647" 
maxArrayLength="2147483647" 
maxBytesPerRead="2147483647" 
maxNameTableCharCount="2147483647" 

Upvotes: 1

Views: 280

Answers (2)

Simon Wilson
Simon Wilson

Reputation: 10424

As Kirk mentioned, try add a behavior to your config similar to below:

<behaviors>
<endpointBehaviors>
<behavior name="MyService.MyServiceBehavior">
 <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>

If this works for you then don't mark me as correct, Kirk you add an answer and I will remove this one

Upvotes: 1

Timwi
Timwi

Reputation: 66573

Here are some solutions you could try:

  • There’s a good chance you could be hitting a timeout issue. Try to set the timeouts on your binding both on the client and the server to something higher than 1 minute (which is the default).
  • Increase maxItemsInObjectGraph in DataContractBehavior.

Otherwise, edit your question to include information about the exception you’re getting and any other information that may be relevant.

Upvotes: 0

Related Questions