title: WCF Inheritance/Polymorphism and Serialization
body: <p>I have a class, <code>ReportDef</code>, which is a concrete class that I've decorated with <code>[DataContract]</code> and <code>[DataMember]</code> attributes as needed.  <code>ReportDef</code> is in assembly <code>A1</code> along with my <code>ServiceContract</code>, <code>IReportService</code>.  I then have another class, <code>UiReportDef</code>, which derives from <code>ReportDef</code> and is in assembly <code>A2</code>.  <code>UiReportDef</code> has no additional state that the service cares about.  </p>
  
  <p>I want to invoke my service with an instance of <code>UiReportDef</code>.  Is there any way (short of manually constructing a <code>ReportDef</code> instance from <code>UiReportDef</code>) to do this without having my service know about <code>A2</code>?  I know about <code>KnownType</code>.  I don't want to reference <code>A2</code>.</p>
  
  <hr>
  
  <p><strong>EDIT:</strong> Here's some context that might make my question easier to understand. My <code>ServiceContract</code> implements <code>IReportService</code> which defines a method, <code>RunReport(ReportDef report)</code>.  <code>ReportDef</code> is decorated with the <code>DataContract</code> attribute, and has private members decorated with <code>DataMember</code>.  <code>UiReportDef</code> is in an assembly that depends on UI-related assemblies, etc. I didn't design the existing class hierarchy.  I need to pass <code>ReportDefs</code> and <code>UiReportDefs</code> (as <code>ReportDefs</code>) to the new service.  Since <code>ReportDef</code> is concrete, I would expect the serializer to treat <code>UiReportDefs</code> as <code>ReportDefs</code> in the absence of any other information.</p>