错误

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. 

解决

服务器端:

ServiceHost host = new ServiceHost(serviceType, uri);
foreach (IServiceBehavior behavior in host.Description.Behaviors)
{
if (behavior is ServiceBehaviorAttribute)
{
(behavior as ServiceBehaviorAttribute).MaxItemsInObjectGraph = int.MaxValue;
}
}

 

客户端:

ChannelFactory<T> channelFactory = new ChannelFactory<T>(binding);
foreach (OperationDescription op in channelFactory.Endpoint.Contract.Operations)
{
DataContractSerializerOperationBehavior dataContractBehavior = op.Behaviors.Find<DataContractSerializerOperationBehavior>() as DataContractSerializerOperationBehavior;
if (dataContractBehavior != null)
{
dataContractBehavior.MaxItemsInObjectGraph = int.MaxValue;
}
}

 

相关文章:

  • 2021-07-17
  • 2022-12-23
  • 2021-07-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
猜你喜欢
  • 2021-05-27
  • 2021-07-24
  • 2021-06-19
  • 2022-12-23
  • 2021-05-04
  • 2022-12-23
  • 2021-09-04
相关资源
相似解决方案