简体   繁体   English

返回服务上的大数据

[英]Return large data on service

I have a method that returns a large list of objects. 我有一个返回大量对象的方法。 When I return a few objects (10) everything works great. 当我返回一些物体(10)时,一切都很好。 The problem is when I try to return 100 objects. 问题是当我尝试返回100个对象时。 The reason why the list is so big is because the objects in the list have other objects inside so I am basically returning a tree. 列表如此之大的原因是因为列表中的对象内部有其他对象,所以我基本上返回了一棵树。

Anyways I am using named pipes and here is the configuration of the enpoint I am using: 无论如何我使用命名管道,这是我正在使用的enpoint的配置:

<netNamedPipeBinding>
      <binding name="NetNamedPipeBinding_ISymbolFileParser" 
                      closeTimeout="00:10:00"
                      openTimeout="00:10:00" 
                      receiveTimeout="00:10:00" 
                      sendTimeout="00:10:00"
                      transactionFlow="false" 
                      transferMode="Buffered" 
                      transactionProtocol="OleTransactions"
                      hostNameComparisonMode="StrongWildcard"
                      maxBufferPoolSize="2147483647"
                      maxBufferSize="2147483647" 
                      maxConnections="10" 
                      maxReceivedMessageSize="2147483647"
                     >
              <readerQuotas 
                   maxDepth="32" 
                   maxStringContentLength="2147483647" 
                   maxArrayLength="2147483647"
                   maxBytesPerRead="4096" 
                   maxNameTableCharCount="2147483647" />                    
      </binding>
</netNamedPipeBinding>

When I limit the number of objects by doing results.Take(10).ToArray(); 当我通过做results.Take(10).ToArray();限制对象的数量时。采取results.Take(10).ToArray(); everything works great. 一切都很好。 When I return 100 objects I get the exception: 当我返回100个对象时,我得到了异常:

在此输入图像描述


Things I have done to try to solve the problem: 我尝试解决问题的方法:

  1. I increase the numbers in the config file to 2147483647 我将配置文件中的数字增加到2147483647
  2. Instead of returning the list of objects I serialized the list my self on the service and then created a Test method that will return byte[] instead of the list. 我没有返回对象列表,而是在服务上序列化了我自己的列表,然后创建了一个将返回byte []而不是列表的Test方法。 Then on the client I deserialize the byte[] to a list and that works! 然后在客户端我将byte []反序列化为一个列表,这是有效的! So I have a solution so far the worst case scenatio would be that I have to serialize the object my serlf and deserialize it. 所以我有一个解决方案到目前为止最糟糕的情况是我必须序列化我的serlf对象并反序列化它。

I will like to take also an opportunity to ask if I should be using a different binding. 我还想借此机会询问我是否应该使用不同的绑定。 I heard that shared memory is the fastes but I don't know how to use that on wcf. 我听说共享内存是紧张的,但我不知道如何在wcf上使用它。 Because I am communicating between the same machine I am using named pipes. 因为我在同一台机器之间进行通信,所以我正在使用命名管道。

Looks like serialization issue, try increase dataContractSerializer maxItemsInObjectGraph thru behaviors in endpointBehaviors and serviceBehaviors. 看起来像序列化问题,尝试通过endpointBehaviors和serviceBehaviors中的行为增加dataContractSerializer maxItemsInObjectGraph

The same problem here 同样的问题在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM