title: Returning a List<SuperType> on a WCF service
body: <p>I am trying to get a WCF service to return a List that contains instances of classes that inherit from A but am getting "The underlying connection unexpectedly closed" when the service returns the list.</p>
  
  <p>I have the following</p>
  
  <pre><code>  [DataContract]
    [Serializable]
    public class A { ... }
  
    [DataContract]
    [Serializable]
    public class B : A { ... }
  
    [DataContract]
    [Serializable]
    public class C : A { ... }
  </code></pre>
  
  <p>I then have a service defined as</p>
  
  <pre><code>[ServiceContract( NameSpace = "Name.Space" )]
  public interface I
  {
      [OperationContract]
      List&lt;A&gt; GetList();
  }
  </code></pre>
  
  <p>If I attempt to return a list as follows</p>
  
  <pre><code>  List&lt;A&gt; list = new List&lt;A&gt;()
    {
      new B(),
      new C()
    }
  </code></pre>
  
  <p>I get the above error in the proxy class.</p>
  
  <p>If a change the service to return List&lt;B&gt; and just add Bs to it it returns fine, so this leads me to believe it is related to WCF having difficulty with the subtypes.</p>
  
  <p>I have tried adding</p>
  
  <pre><code>  [ServiceKnownType( typeof( B ) )]
    [ServiceKnownType( typeof( C ) )]
  </code></pre>
  
  <p>To the class defintion of A, to no avail.</p>
  
  <p>So, is it possible to return a list of subtypes in the same list through WCF?</p>
  
  <p>If so, what am I missing/doing wrong?</p>
  
  <p>Thanks in advance for any assistance you can provide</p>