I know this has been asked a few times, but I tried all the solutions on stackoverfolow and none of them seemed to work so here it goes :
I have a service (running on NetTCP binding) which just waits for connections and assigns work to another service when called, the data it passes is huge and thus I am recieveing this error :
Maximum number of items that can be serialized or deserialized in an object graph is '65536'”
below is my config :
<services>
<service behaviorConfiguration="CoreBehavior" name="PrepService">
<endpoint address="net.tcp://localhost/Preparation"
binding="netTcpBinding"
contract="IWorkManagerService"
bindingConfiguration="CoreTcpBinding"/>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="CoreTcpBinding" closeTimeout="00:10:00" openTimeout="00:10:00"
sendTimeout="00:10:00" maxBufferSize="2147483647"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="64" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="CoreBehavior">
<serviceMetadata httpGetEnabled="false" />
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
As you can see in my CoreTcpBinding I have pretty much maxed out all configuration values but I still keep getting the same error, I'm just stumped as to why does it default to "65536" ?
The service (client) that calls the above defined service has the following configuration:
<services>
<service behaviorConfiguration="CoreBehavior" name="AssignmentService">
<endpoint address="net.tcp://localhost:8001/Assignment"
binding="netTcpBinding"
contract="IWorkerService"
bindingConfiguration="CoreTcpBinding"/>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="CoreTcpBinding"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="CoreBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
The client talks to the Server via proxy as usual :
var proxy = new PrepServiceProxy(new NetTcpBinding(), new EndpointAddress(ServiceAddress));
Proxy Code :
public PrepServiceProxy(Binding binding, EndpointAddress remoteAddress) : base(binding, remoteAddress)
{
var netTcpBinding = binding as NetTcpBinding;
if (netTcpBinding != null)
(netTcpBinding).Security.Mode = SecurityMode.None;
}
You have to configure this at client and server side. Make sure you have the dataContractSerializer maxItemsInObjectGraph="2147483647" at both sides.