c# - .net XmlSerializer on overridden properties -


i have base class abstract property:

public abstract int id {get;set;} 

now, have subclass, xmlserialized. so, has:

[xmlelement("something")] public override int id { { //... } set { //... } } 

i cannot move xmlelement attribute baseclass, since every subclass have different xml elementname.

now, when deserialize class following error:

member 'subclass.id' hides inherited member 'baseclass.id', has different custom attributes.

what can do?

serialization , deserialization of derived types works when overridden properties have [xmlelement] , [xmlattribute] attributes, adding [xmlignore] attribute.

the base class can made abstract can never instantiated , therefore serialized or deserialized.

[serializable] public abstract class base {     [xmlignore]     public abstract int32 id { get; set; } } 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -