嘗試通過WCF服務傳遞DTO時,出現以下異常。WCF最大讀取深度異常
System.Xml.XmlException: The maximum read depth (32) has been exceeded because XML data being read has more levels of nesting than is allowed by the quota. This quota may be increased by changing the MaxDepth property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 5230.
at System.Xml.XmlExceptionHelper.ThrowXmlException
在app.config結合看起來像這樣
<binding name="WSHttpBinding_IProjectWcfService" closeTimeout="00:10:00"
openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="10240000" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="200" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="">
<extendedProtectionPolicy policyEnforcement="Never" />
</transport>
<message clientCredentialType="UserName" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
Web.config文件服務行爲:
而且DTO是這樣的:
[Serializable]
[DataContract(IsReference=true)]
public class MyDto
{
任何幫助將不勝感激,因爲我用它拉我的頭髮。
你改變客戶端和服務器上的配置?我有這樣的印象,我必須在兩者之前匹配這一變化。 – 2010-03-25 00:22:55
非常不尋常的嵌套那很深。你可能有一個循環引用。我想我們需要看到更多的DTO;改變最大嵌套可能只是一個創可貼解決方案。 – Aaronaught 2010-03-25 02:16:43
我解決了我的問題,因爲我在這裏解釋:http://stackoverflow.com/questions/5537794/error-while-deserializing-the-object-in-wcf – Adi 2011-12-07 13:18:16