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 一样;

 

posted @ 2017-07-13 17:26  hi.....  阅读(279)  评论(0编辑  收藏  举报