- public class Test
- {
- private string _Field = "";
- public string Field
- {
- get { return _Field; }
- set { _Field = value; }
- }
- }
- public class TestInherited : Test
- {
- }
- public class Container
- {
- private Test ivField;
- public Test Field
- {
- get { return _Field; }
- set { _Field = value; }
- }
- }
- Container _Test = new Container();
- _Test.Field = new TestInherited();
Solution:
new XmlSerializer(typeof(Container), new Type[] { typeof(TestInherited) });
This solution was not working for me because:
There was a namspace on my XmlRoot element [XmlRoot("Container", Namespace = "http://namespace", IsNullable = false)]
When i removed namespase, the problem was gone.
Hope this helps someone.