XML文件名

<?xml version="1.0" encoding="utf-8"?>
<Config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Enabled>true</Enabled>
  <serverURL>http://127.0.01/Version.xml</serverURL>
  <updateFileList updateInfo="更新说明信息">
    <localFile fileName="bb.exe" fileVersion="" />
  </updateFileList>
</Config>

 

程序代码

XmlSerializer xmlSerializer = new XmlSerializer(typeof(configuration));
            StreamWriter streamWriter = new StreamWriter(file);
            xmlSerializer.Serialize(streamWriter, this);
            streamWriter.Close();

 

出现错误

XML 文档(2, 2)中有错误:不应有 <xml xmlns=''>

 

原因是因为:xml的根节点(Config)和对象名(configuration)不一样导致的不能反序列化,只要请其中一个名称改为和另一个一样就可以通过

相关文章:

  • 2021-12-13
  • 2021-06-13
  • 2021-07-15
  • 2021-10-10
  • 2021-06-04
  • 2021-06-24
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-10
  • 2022-12-23
  • 2022-12-23
  • 2022-03-07
  • 2021-07-16
  • 2021-07-06
相关资源
相似解决方案