2012-09-17 24 views
3

我知道這已被問了幾次,但我嘗試了stackoverfolow上的所有解決方案,並且它們都沒有工作。這裏有雲:WCF「在對象圖中可以序列化或反序列化的項目的最大數量是'65536'」

我有一個服務(上NetTCP結合運行),它只是等待連接,分配工作時調用其他服務,它傳遞的數據是巨大的,因此我recieveing此錯誤:

在對象圖中可以序列化或反序列化的項目的最大數目是'65536'「

下面是我的配置:

<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> 

正如你可以在我的CoreTcpBinding看,我幾乎刷爆了所有配置值,但我還是繼續得到同樣的錯誤,我只是難倒,爲什麼它默認爲「65536」?

服務(客戶端)調用上面定義的服務具有以下配置:

<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> 

通過代理服務器的客戶機與服務器像往常一樣:

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;   

     } 
+0

我看到在您的服務器配置中,端點協定屬性不是完全限定的名稱。確保它是完全限定的(即需要在接口名稱前面有命名空間) – Rajesh

+0

http://stackoverflow.com/questions/7476853/wcf-error-maximum-number-of-items-that-c​​an-be-序列化或反序列化的 –

回答

3

您必須配置該在客戶端和服務器端。確保雙方都有dataContractSerializer maxItemsInObjectGraph =「2147483647」。

+0

請參閱我上面的編輯。 –

+0

雙方非常重要 –

+0

如果您在上面檢查,我已經添加了上面包含maxItemsInObjectGraph =「2147483647」的客戶端服務配置 - 仍然是同樣的錯誤。 –

相關問題