生成XML文档时出错

时间:2014-10-18 10:06:43

标签: c# xml

我使用以下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文档时出错。

有人可以告诉我这里有什么问题吗?

0 个答案:

没有答案