I searched for a while and found no answer.
I'm using the DataContractSerializer. Is it possible to make it skip the serialization of a base property?
Base class:
[KnownType(typeof(DerivedClass))]
[DataContract]
public class BaseClass
{
[DataMember(IsRequired = false)]
public virtual int BaseProperty{ get; set; }
//...
//Many other properties with [DataMember]
}
Derived class:
[DataContract]
public class DerivedClass : BaseClass
{
// *** NO [DataMember] here***
public override int BaseProperty
{
get
{
throw new NotSupportedException("Does not apply");
}
set
{
throw new NotSupportedException("Does not apply");
}
}
}
In this case, I see the error message:
System.Runtime.Serialization.SerializationException: 'Error in line 1 position 248...Expecting element 'BaseProperty'.