0

When I add a normal property of type string I have no problem to deserialize an old file. But If I add a more complex type like a Dictionary<,> it isn't working. I get an exception like "xml don't correspand to the given class" (sorry I only have the exception-message in german)

How can I get this to work without coding a fallback-mode to the old class?

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>();
    }
}
masterchris_99
  • 2,683
  • 7
  • 34
  • 55
  • 1
    XMLSerializer doesn't support Dictionary. Have a look at this question and the answers: http://stackoverflow.com/questions/2911514/why-doesnt-xmlserializer-support-dictionary – Gareth Aug 02 '13 at 08:55
  • May be this [link](http://stackoverflow.com/questions/495647/serialize-class-containing-dictionary-member) can give you some pointer. – Nilesh Aug 02 '13 at 09:00
  • ahh yes of course. Sorry I misinterpreted the message! :-) – masterchris_99 Aug 02 '13 at 09:01

1 Answers1

1

A class implementing IDictionary is not serializable!

see Serialize Class containing Dictionary member

Community
  • 1
  • 1
DerApe
  • 3,097
  • 2
  • 35
  • 55