2012-07-12 65 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请求的返回错误页面的响应流。

相关问题