2014-09-26 83 views
0

添加服務器和客戶端的maxItemsInObjectGraph =「2147483647」參數後,我遇到了上述錯誤。 但是,在我的項目中,可以使用「數據表」對象傳輸大量數據而沒有任何問題。 使用「列表<>」對象傳輸的大量數據發生此錯誤。
我的dotnetframework是4.0,但是我發現這個錯誤在dotnetframework 4.5中找不到,大量數據可以使用「列表<>」對象傳輸而沒有錯誤。這也是Windows基礎項目。WCF錯誤 - '對象圖中可以序列化或反序列化的項目的最大數目是'65536'

請任何人都可以解決這個問題。這是我的服務器和客戶端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

最大接收郵件大小爲2GB?你想在這裏做什麼? – Groo 2014-09-26 09:00:39

+0

我已將其縮小爲512 MB。但它不工作..! – Chamal 2014-09-26 10:32:35

+0

爲什麼你的客戶端配置中有''部分?它應該是''。 – Tim 2014-09-26 18:39:15

回答

0

最後我發現我錯在客戶端配置和我解決我的問題

我的錯誤是behaviorConfiguration = 「CommonBehavior」標籤不在客戶端,終端部分。添加此部分後,問題被成功解決,大量記錄存在通用列表我可以從服務器傳輸到客戶端。

這是我糾正客戶端配置 -

<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> 
相關問題