【发布时间】:2011-12-07 13:24:46
【问题描述】:
报告了在客户端计算机上发生了以下异常:
System.ArgumentException: '', hexadecimal value 0x1F, is an invalid character.
at System.Xml.XmlUtf8RawTextWriter.InvalidXmlChar(Int32 ch, Byte* pDst, Boolean entitize)
at System.Xml.XmlUtf8RawTextWriter.WriteElementTextBlock(Char* pSrc, Char* pSrcEnd)
at System.Xml.XmlUtf8RawTextWriter.WriteString(String text)
at System.Xml.XmlUtf8RawTextWriterIndent.WriteString(String text)
at System.Xml.XmlWellFormedWriter.WriteString(String text)
at System.Xml.Linq.ElementWriter.WriteElement(XElement e)
at System.Xml.Linq.XElement.WriteTo(XmlWriter writer)
at System.Xml.Linq.XElement.Save(XmlWriter writer)
at System.Xml.Linq.XElement.Save(String fileName, SaveOptions options)
at System.Xml.Linq.XElement.Save(String fileName)
很遗憾,没有更多信息可用。
这个错误有点莫名其妙。
0x1F 是一个问号。如果某个元素或属性的名称中包含问号(这是非法的),则在创建具有无效名称的XElement 或XAttribute 时会引发异常,而不是在保存到磁盘时引发异常。
这个异常是由XmlUtf8RawTextWriter 类引发的,我猜这是XElement 在内部使用的(应用程序没有)。不能指望XElement 自己处理编码问题等吗?什么可能导致它崩溃?是操作系统或框架不兼容吗?
我知道我的问题相当模糊,但我必须根据有限的信息进行操作。
如果有人至少能指出我正确的方向,我将不胜感激。我以前从未见过这样的错误。
【问题讨论】:
标签: c# xml exception .net-3.5 xelement