2022年3月3日 星期四

[除錯] 請變更物件圖形或增加 MaxItemsInObjectGraph 配額

環境:

Client:
Winform 3.5 framework 


錯誤訊息:

嘗試將訊息還原序列化時,格式子發生例外狀況: 嘗試將參數 http://tempuri.org/:Get鋼管庫存表SqlClientResult 還原序列化時發生錯誤。InnerException 訊息為 '物件圖形中可以序列化或還原序列化的項目數目上限是 '65536'。請變更物件圖形或增加 MaxItemsInObjectGraph 配額。 '。如需詳細資訊,請參閱 InnerException。


解決:

修改客戶端app.config [新增紅色部份]

        <behaviors>

          <endpointBehaviors>

            <behavior name="NewBehavior">

              <dataContractSerializer maxItemsInObjectGraph="2147483647"/>

            </behavior>

          </endpointBehaviors>

        </behaviors>

  

        <bindings>

            <basicHttpBinding>

                <binding name="BasicHttpBinding_IService1" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />

            </basicHttpBinding>

        </bindings>

        <client>

            <endpoint address="http://localhost:1093/Service1.svc"  binding="basicHttpBinding" behaviorConfiguration="NewBehavior"

                bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1"

                name="BasicHttpBinding_IService1" />

        </client>


參考:

WCF中如何修改MaxItemsInObjectGraph的限制

WCF測試錯誤碼

MaxItemsInObjectGraph

[ASP.NET] WCF 傳輸超過 65536 的資料


其它參考:

解决进行反序列化时出错:。InnerException 消息是“反序列化对象 属于类型 System.String 时出现错误。读取 XML 数据时,超出最大字符串内容长度配额

maxReceivedMessageSize and maxBufferSize in app.config



沒有留言:

張貼留言