Exception when returning a shared list from WCF

Hi, I'm stuck in a weird problem,

I have a general List<Accounts> list that is populated from the database, then this list is returned to the client.

When a list contains more than 3,000 items, it throws an exception.

I set the following values ​​in web.config

 maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" 
+1
source share
2 answers

As Kirk mentioned, try adding behavior to your configuration as shown 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 adds the answer, and I will delete this

+1
source

Here are some solutions you could try:

  • Theres a good chance that you might run into a timeout problem. Try to set timeouts in your binding both on the client and on the server for more than 1 minute (this is the default value).
  • Increase maxItemsInObjectGraph in DataContractBehavior.

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

0
source

Source: https://habr.com/ru/post/1345550/


All Articles