![](/img/trans.png)
[英]Windows Identity Foundation System.Xml.XmlException: Unexpected end of file
[英]System.Xml.XmlException: Unexpected end of file while parsing Name has occurred
我正在使用通過SqlCommand.ExecuteXmlReader
檢索的XmlReader
。
當我運行以下代碼行時:
XDocument currentXDoc = XDocument.Load(ktXmlReader.ReadSubtree());
它第一次運行,按預期方式讀取第一個Product節點。
第二次運行時,出現以下異常:
System.Xml.XmlException:
Message: Unexpected end of file while parsing Name has occurred. Line 1, position 2048.
Stacktrace: at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.ParseQName(Boolean isQName, Int32 startOffset, Int32& colonPos)
at System.Xml.XmlTextReaderImpl.ThrowTagMismatch(NodeData startTag)
at System.Xml.XmlTextReaderImpl.ParseEndElement()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at System.Xml.XmlSubtreeReader.Read()
at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r)
at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o)
at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
我確實找到了這個問題 , 這個問題與我的類似,但是我相當確定我的XML格式正確(我可以通過運行sproc來直接獲取它)
到目前為止,我的想法是:
XDocument
或XmlReader
某個地方遇到2KB的限制嗎? XmlReader執行是一種操作方式。 您可以嘗試重置其位置,或者更容易- 從現有文檔中創建一個新的閱讀器 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.