Let\'s say that I have two classes, a base class and a derived class. They are fairly simple classes, and mainly just act as data structures (with the derived class obviousl
Well, I've managed to do what you're trying to do using the DataContractSerializer.
You should either put KnownTypes attribute on the base classes you want to serialize, or better yet, use a DataContractResolver to find the derived types.
I've seen a generic implementation on the web, I'll post it here if I find it again.
Edit
Found it here
Let me know if you need more help.
XmlSerialization is not polymorphic (the member attributes, however, go with the declaring class; i.e. unless you overrule a member with the new
keyword (in contrast to override
) you'll 'inherit' the serialization attributes.
Deserialization always results in the actual type that was serialized. This makes a lot of sense, really.