none
对象图中可以序列化或反序列化的项目数目上限为“65536”。请更改对象图或增加 MaxItemsInObjectGraph 的配额。这是什么问题呢? RRS feed

  • 问题

  • 今天做了一个wcf的小例子,遇到一个奇怪的问题,每次传送小数据量可以,大数据量总报错,传送了10000个对象,一个对象里面有6个字符串,按理说应该可以传2G的,实在找不到原因


    报错:
    格式化程序尝试对消息反序列化时引发异常: 尝试对参数 http://tempuri.org/ 进行反序列化时出错: GetAllBooksResult。InnerException 消息是“对象图中可以序列化或反序列化的项目数目上限为“65536”。请更改对象图或增加 MaxItemsInObjectGraph 的配额。 ”。有关详细信息,请参阅 InnerException。

    我的服务端配置文件:
    <behaviors>
    <serviceBehaviors>
    <behavior name="NewBehavior">
    <serviceMetadata httpGetEnabled="true"/>
    <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
    </behavior>
    </serviceBehaviors>

    <endpointBehaviors>
    <behavior name="endPointBehavior" >
    <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
    </behavior>
    </endpointBehaviors>
    </behaviors>

    <services>
    <service behaviorConfiguration="NewBehavior" name="Services.BookService">
    <endpoint address="basic" behaviorConfiguration="endPointBehavior"
    binding="basicHttpBinding" bindingConfiguration="basicHttpBindingConfiguration"
    contract="Services.IBookService" listenUriMode="Explicit" />
    <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
    contract="IMetadataExchange" />
    <host>
    <baseAddresses>
    <add baseAddress="http://localhost:8081/BookService" />
    </baseAddresses>
    </host>
    </service>
    </services>

    <bindings>
    <basicHttpBinding>
    <binding name="basicHttpBindingConfiguration" textEncoding="UTF-8" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" openTimeout="00:10:00" sendTimeout="00:10:00" receiveTimeout="00:10:00" >
    <readerQuotas maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147483647" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647" />
    </binding>
    </basicHttpBinding>
    </bindings>


    客户端调用的代码:
    string serviceUrl = @"http://localhost:8081/BookService/basic";
    BasicHttpBinding bing = new BasicHttpBinding(BasicHttpSecurityMode.None)
    {
    MaxBufferSize = 2147483647,
    MaxReceivedMessageSize = 2147483647,
    MaxBufferPoolSize = 2147483647,
    ReceiveTimeout = new TimeSpan(0, 10, 0),
    SendTimeout = new TimeSpan(0, 10, 0)
    };
    WS.BookServiceClient client = new Client.WS.BookServiceClient(bing, new EndpointAddress(serviceUrl));
    client.GetAllBooksCompleted += new EventHandler<Client.WS.GetAllBooksCompletedEventArgs>(client_GetAllBooksCompleted);
    client.GetAllBooksAsync();

    2011年7月29日 16:43

答案

全部回复