我知道這已被問了幾次,但我嘗試了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;
}
我看到在您的服務器配置中,端點協定屬性不是完全限定的名稱。確保它是完全限定的(即需要在接口名稱前面有命名空間) – Rajesh
http://stackoverflow.com/questions/7476853/wcf-error-maximum-number-of-items-that-can-be-序列化或反序列化的 –