In WCF, how to inherit from a class which is not marked with DataContractAttribute or SerializableAttribute and use that as datacontract ?
Ex: I have a custom class called "EmailAttachment" which I inherited from System.Net.Mail.Attachment:
[DataContract]
public class EmailAttachment : Attachment
{
[DataMember]
public string AttachmentURL
{
set;
get;
}
[DataMember]
public string DisplayName
{
set;
get;
}
}
But when I publish the service, it's throwing a runtime error saying that:
System.Runtime.Serialization.InvalidDataContractException: Type 'EmailAttachment' cannot inherit from a type that is not marked with DataContractAttribute or SerializableAttribute.
What's the workaround for this?