文字列型の通常のプロパティを追加すると、古いファイルを逆シリアル化するのに問題はありません。しかし、 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>();
}
}