El TecnoBaúl de Kiquenet

Kiquenet boring stories

How to set the MaxItemsInObjectGraph configuration.

Posted by kiquenet en 20 julio 2010

Symptoms/Exceptions:

("System.Runtime.Serialization.SerializationException : Maximum number of items that can be serialized or deserialized in an object graph is ‘65536’. Change the object graph or increase the MaxItemsInObjectGraph quota.").

"System.ServiceModel.CommunicationException: The underlying connection was closed: The connection was closed unexpectedly"

Solution

You need to modify both the configuration file for the service as well as the client.

For the services configuration should look like this:

<system.serviceModel>   
<services>
      <service
behaviorConfiguration="Umea.se.EventReactor.ServiceTier.ServiceViewEventBehavior"
       name="Umea.se.EventReactor.ServiceTier.ServiceViewEvent">
        <endpoint address="" binding="wsHttpBinding" contract="Umea.se.EventReactor.ServiceTier.IServiceViewEvent">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="Umea.se.EventReactor.ServiceTier.ServiceViewEventBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

The client configuration should look like this:

<system.serviceModel>
    <client>
<endpoint address="
http://localhost:3379/ServiceViewEvent.svc" behaviorConfiguration="ServiceViewEventBehavior"
        binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IServiceViewEvent"
        contract="ServiceReferenceViewEvent.IServiceViewEvent" name="WSHttpBinding_IServiceViewEvent">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
</client>
<behaviors>
      <endpointBehaviors>
        <behavior name="ServiceViewEventBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
      </endpointBehaviors>
</behaviors>
  </system.serviceModel>

http://blog.hill-it.be/post/2007/08/22/MaxItemsInObjectGraph-and-keeping-references-when-serializing-in-WCF

http://processmentor.com/community/blogs/scott_middleton/archive/2007/06/08/169.aspx

Anuncios

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s

 
A %d blogueros les gusta esto: