I have a base class with a property called Name, which has an XmlText attribute.
When an inherited class is serialized I get an exception saying:
There was an error reflecting type '[type name]'. ---> System.InvalidOperationException: Cannot serialize object of type '[type name]'. Base type '[base type name]' has simpleContent and can only be extended by adding XmlAttribute elements. Please consider changing XmlText member of the base class to string array.
Here are my class definitions, the error occures when serializing to xml.
[Serializable]
public class LookupItem
{
[System.Xml.Serialization.XmlAttribute()]
public int ID { get; set; }
[System.Xml.Serialization.XmlText()]
public string Name { get; set; }
}
[Serializable]
public class Vendor : LookupItem
{
public string ContactNumber { get; set; }
}
[Serializable]
public class Vendors : List<Vendor>
{
}