当我添加string类型的普通属性时,我没有问题反序列化旧文件。但是,如果我添加一个更复杂的类型,如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>();
}
}