John Soer
John Soer

Reputation: 551

Serialization of a derived class that hides a base property

I have a class like this

MyClass : BaseClass
    string new FirstName

When I try to serialize this class I get the following error message

Member SQLClientAdapter.Columns of type hides base class member Adapter.Columns of type ...Use XmlElementAttribute or XmlAttributeAttribute to specify a new name.

The recomendation did not work.

Google recommended to add the Ignore() attribute to the base class however I'm not able to modify the base class.

Upvotes: 1

Views: 1717

Answers (1)

Krzysztof Kozmic
Krzysztof Kozmic

Reputation: 27374

Implement ISerializable and do serialization manually or do what the exception message says - rename the property in inherited type in your serialization stream.

Upvotes: 0

Related Questions