在代码中:
foreach (OperationDescription op in factory.Endpoint.Contract.Operations)
{
DataContractSerializerOperationBehavior dataContractBehavior =
op.Behaviors.Find<DataContractSerializerOperationBehavior>()
as DataContractSerializerOperationBehavior;
if (dataContractBehavior != null)
{
dataContractBehavior.MaxItemsInObjectGraph = 100000;
}
}
在配置中:
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaivor">
<serviceAuthorization impersonateCallerForAllOperations="True" />
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceThrottling maxConcurrentCalls="2147483647" />
<dataContractSerializer maxItemsInObjectGraph="65775" />
</behavior>
</serviceBehaviors>
</behaviors>