Search code examples
c#wcfnamed-pipeslarge-data

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. The problem is when I try to return 100 objects. 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:

<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(); everything works great. When I return 100 objects I get the exception:

enter image description here


Things I have done to try to solve the problem:

  1. I increase the numbers in the config file to 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. Then on the client I deserialize the byte[] to a list and that works! 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.

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. Because I am communicating between the same machine I am using named pipes.


Solution

  • Looks like serialization issue, try increase dataContractSerializer maxItemsInObjectGraph thru behaviors in endpointBehaviors and serviceBehaviors.

    The same problem here