title: DataContract Serialize abstract class
body: <p>I have an interface IServiceInfo and an abstract class ServiceInfo. There are several classes inherited from ServiceInfo, like CoreServiceInfo, ModuleServiceInfo etc. There is a service contract named RootService which returns IServiceInfo. </p>
  
  <pre><code> public IServiceInfo GetServiceInfo()
   {
       return (IServiceInfo)new CoreServiceInfo();
   }
  </code></pre>
  
  <p>I am having problem serializing. I can use ServiceKnownType to identify base class, and KnownType to identify child class.</p>
  
  <p>Problem is I do not know all the ServiceInfo child, since application can have plugins with different child inherited from ServiceInfo, so I cannot tell serializer to have all the child in serialized XML.</p>
  
  <p>I can ignore abstract class, but it contains certain common implementation so I need to keep it. As a work around I can have another class say "sampleServiceInfo" and convert all the info classes to sampleServiceInfo and return it from Service method, and define KnownType to ServiceInfo class.</p>
  
  <pre><code>[KnownType(typeof(sampleServiceInfo))]
  public class ServiceInfo : IServiceInfo
  </code></pre>
  
  <p>But that does not sound pretty way to do it. Please suggest. Do I need to write custom serializer? Is there any way to serialize base only and ignoring the child when both has same members?</p>