当我添加字符串类型的普通属性时,反序列化旧文件没有问题。但是如果我添加一个更复杂的类型,比如 Dictionary<,>,它就不起作用了。我收到一个异常,例如“xml 与给定的类不对应”(对不起,我只有德语的异常消息)
如何在不为旧类编写后备模式的情况下使其工作?
public class Connection2Sap
{
[XmlAttribute]
public string Name { get; set; }
public string Server { get; set; }
public string Username { get; set; }
public Connection2SapPassword Password { get; set; }
public string SystemNumber { get; set; }
public string Client { get; set; }
public string Language { get; set; }
public bool MockModeEnabled { get; set; }
public Dictionary<string, string> AdditionalConfigParameters { get; set; } // NEW!
public Connection2Sap()
{
Password = new Connection2SapPassword();
AdditionalConfigParameters = new Dictionary<string, string>();
}
}