The maximum number of elements that can be serialized or deserialized in an object graph ... using knowtypes

In the WCF 4.0 service, we get a huge amount of data in the general list. This graph of the list of objects is larger than the default limit of 65536. We are pretty used to it, so we configured the service to get these large graphs.

<serviceBehaviors> <behavior> <dataContractSerializer maxItemsInObjectGraph="2147483647" /> </behavior> </serviceBehaviors> 

With the above piece of xml config, we avoided the problem in the past without any problems, but now it will not work. The only difference is that here we use KnownTypes in the huge list items that we are trying to deserialize in the WCF method.

Maybe I missed some special configuration for known types?

+6
source share
2 answers

Remember to check the client configuration.

See similar answers in How to fix MaxItemsInObjectGraph error?

You need to set MaxItemsInObjectGraph to dataContractSerializer, using both client and service behavior.

and ignore maxItemsInObjectGraph

I forgot to put this parameter in my client app.config file

.

+7
source

For http://wcf.codeplex.com/discussions/258278 , put the following ServiceBehavior attribute in the class definition as follows:

 [ServiceContract] [ServiceBehavior(MaxItemsInObjectGraph = int.MaxValue)] public class MaintenanceResource 
+1
source

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


All Articles