title: Why can I not use the KnownType attribute in my WCF class?
body: <p>I am using WCF to retrieve a collection of objects.  The objects are all of type ProcedureText but may be of child classes SuspensionText or ResumptionText, both of which inherit from ProcedureText.</p>
  
  <pre><code>public class ProcedureText { }
  public class SuspensionText : ProcedureText { }
  public class ResumptionText : ProcedureText { }
  </code></pre>
  
  <p>My OperationContract specifies a method returning an array of ProcedureText objects:</p>
  
  <pre><code>[OperationContract]
  [WebGet(UriTemplate = "procedureTexts")]
  ProcedureText[] GetProcedureTexts();
  </code></pre>
  
  <p>This works if I cast all my objects to ProcedureText but I want to keep the distinction of using the sub-types.  I had hoped to use the KnownType attribute to do this and had expected to be able to do it by adding it to my ProcedureText class:</p>
  
  <pre><code>[System.Runtime.Serialization.KnownType(typeof(SuspensionTextDto))]
  [System.Runtime.Serialization.KnownType(typeof(ResumptionTextDto))]
  public class ProcedureText { }
  </code></pre>
  
  <p>This doesn't work because the compiler cannot resolve System.Runtime.Serialization.KnownType.  I know from the document that the attribute is part of .NET Framework 4, but I am using .NET Framework 4 and that is the Target Frameweork for my project.</p>
  
  <p>Why do I need to set to be able to use the attribute?</p>