我使用以下C#代码创建XML文件:
private void CreateXML()
{
_logger.Log("Creating XML....");
XmlWriterSettings xmlWriterSettings = new XmlWriterSettings
{
Indent = true,
OmitXmlDeclaration = false,
Encoding = Encoding.UTF8,
CheckCharacters = true
};
XmlSerializer serializer = new XmlSerializer(typeof(List<Page>));
using (XmlWriter writer = XmlWriter.Create(_outputXMLFilePath, xmlWriterSettings))
{
serializer.Serialize(writer, this._pages);
}
_logger.Log("XML Created");
}
在线serializer.Serialize(writer, this._pages);
我收到以下异常:
System.Xml.dll中出现未处理的“System.InvalidOperationException”类型异常
其他信息:生成XML文档时出错。
有人可以告诉我这里有什么问题吗?