2012-07-12 42 views
2

當我流汗的字節的數據,我想轉換成的XElement像下面XElement.Load(流)拋出System.NotSupportedException

using (Stream streamResult = new MemoryStream(byteArray)) 
{ 
    XElement xElement = XElement.Load(streamResult); // exception thrown here 
} 

這裏的異常詳細信息:

一'System.NotSupportedException' 類型 的第一次機會異常出現在system.xml.dll的PageRequest ::後處理: System.NotSupportedException:NotSupportedException異常在 System.Xml.XmlTextReaderImpl.ParseText(的Int32 & startPos,的Int32 & endPos, 的Int32 & outOrChars)處 System.Xml.XmlTextReaderImpl.get_Value() System.Xml.XmlTextReaderImpl.FinishPartialValue()在 System.Xml.Linq.XContainer.ReadContentFrom(的XmlReader r)是 System.Xml.Linq.XContainer.ReadContentFrom(XmlReader中R,LoadOptions O) 在System.Xml.Linq.XElement.ReadElementFrom(XmlReader中R,LoadOptions O)在System.Xml.Linq.XElement..ctor(的XmlReaderř ,LoadOptions O)
在System.Xml.Linq.XElement.Load(的XmlReader讀取器,LoadOptions 選項)在System.Xml.Linq.XElement.Load(流流, LoadOptions選項)

是XML的問題嗎?

+0

原因包含在異常詳細信息中。如果沒有Message屬性的內容以及任何InnerException,就不能真正回答(除非你有完全相同的問題)。 – Will 2012-07-12 13:12:57

+0

好的,我會更新它 – Rakesh 2012-07-12 13:18:35

+0

這就是我可以幫助你。看起來所有的API都是正確的。可能是在XML中的東西。 – Will 2012-07-12 15:07:13

回答

0

當我的Windows Phone應用程序中的流沒有包含有效的XML時,我遇到了System.NotSupportedException異常。

在我的情況下,我在某些情況下使用來自Web請求的返回錯誤頁面的響應流。

相關問題