我添加了maxItemsInObjectGraph =" 2147483647"参数服务器和客户端。
但是在我的项目中,可以使用" datatable"来传输大量数据。对象没有任何问题。
使用" List<>"传输大量数据时发生此错误。对象。
我的dotnetframework是4.0,但我发现在dotnetframework 4.5中找不到这个错误,大量数据可以使用" List<>"对象没有错误。这也是Windows基础项目。
请有人能解决这个问题。这是我的服务器和客户端app.cofig配置。
谢谢!
我的服务;
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="CommonBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceMetadata httpGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceThrottling
maxConcurrentSessions="1200"
maxConcurrentCalls="192"
maxConcurrentInstances="1392"
/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding maxReceivedMessageSize="2147483647" name="netTcpBinding" transferMode="Streamed" listenBacklog="2000" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="2000"
closeTimeout="08:00:00" openTimeout="08:00:00" receiveTimeout="08:00:00" sendTimeout="08:00:00">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="08:00:00"
enabled="false" />
<security mode="None">
<transport clientCredentialType ="None"/>
</security>
</binding>
</netTcpBinding>
</bindings>
<services>
<service behaviorConfiguration="CommonBehavior" name="MyBLL">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="netTcpBinding" name="MyEndPoint" contract="IMy">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8000/MySVC"/>
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
我的客户;
<system.serviceModel>
<client>
<endpoint name="MyEndPoint" address="net.tcp://localhost:8000/MySVC" binding="netTcpBinding" bindingConfiguration="netTcpBinding" contract="IMy" />
</client>
<behaviors>
<endpointBehaviors>
<behavior name="CommonBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding name="netTcpBinding" maxReceivedMessageSize="2147483647" transferMode="Streamed" listenBacklog="2000" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="2000"
closeTimeout="08:00:00" openTimeout="08:00:00" receiveTimeout="08:00:00" sendTimeout="08:00:00">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="08:00:00"
enabled="false" />
<security mode="None">
<transport clientCredentialType ="None"/>
</security>
</binding>
</netTcpBinding>
</bindings>
<services>
<service behaviorConfiguration="CommonBehavior" name="MyEndPoint">
<endpoint address="" behaviorConfiguration="CommonBehavior" binding="netTcpBinding" bindingConfiguration="netTcpBinding" name="MyEndPoint" contract="Imy">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8000/MySVC" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
答案 0 :(得分:0)
最后我在客户端配置中发现了我的错误,我解决了我的问题。
我的错误是 behaviorConfiguration =&#34; CommonBehavior&#34; 标记不在客户端,端点部分。添加此部分后,问题已成功解决,大量记录存在通用列表我可以从服务器转移到客户端。
这是我更正的客户端配置 -
<system.serviceModel>
<client>
<endpoint name="MyEndPoint" behaviorConfiguration="CommonBehavior" address="net.tcp://localhost:8000/MySVC" binding="netTcpBinding" bindingConfiguration="netTcpBinding" contract="IMy" />
</client>
<behaviors>
<endpointBehaviors>
<behavior name="CommonBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding name="netTcpBinding" maxReceivedMessageSize="2147483647" transferMode="Streamed" listenBacklog="2000" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="2000"
closeTimeout="08:00:00" openTimeout="08:00:00" receiveTimeout="08:00:00" sendTimeout="08:00:00">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="08:00:00"
enabled="false" />
<security mode="None">
<transport clientCredentialType ="None"/>
</security>
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>