serviceBehaviors_dataContractSerializer_maxItemsInObjectGraph 关键**Behavior

       <behaviors>
      <serviceBehaviors>
        <behavior name="STHotel.Product.WCFService.HotelProductBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
</serviceBehaviors>
    </behaviors>
              var xd = sh.AddServiceEndpoint(item.jk, tp2, add);


                    DataContractSerializerOperationBehavior dataContractBehavior = xd.Behaviors.Find<DataContractSerializerOperationBehavior>() as DataContractSerializerOperationBehavior;
                    if (dataContractBehavior != null)
                    {
                        dataContractBehavior.MaxItemsInObjectGraph =int.MaxValue;
                    }


    DataContractSerializerOperationBehavior tttt = sh.Description.Behaviors[typeof(DataContractSerializerOperationBehavior)] as DataContractSerializerOperationBehavior;
                    tttt.MaxItemsInObjectGraph = int.MaxValue;

  ServiceDebugBehavior debugBehavior = sh.Description.Behaviors[typeof(ServiceDebugBehavior)] as ServiceDebugBehavior;
                    debugBehavior.IncludeExceptionDetailInFaults = true;
ServiceMetadataBehavior 一样;
原文地址:https://www.cnblogs.com/xiangxiong/p/7161643.html