title: cast 'object' type property to knownType in wcf client
body: <p>I have created a WCF service with a simple method with a property of type 'object' because this property is intended to be used with different types of objects, but when i cast the property to another type it throws an invalidCastException. The Service looks like this:</p>
  
  <pre><code>[ServiceContract]
  [ServiceKnownType(typeof(List&lt;ItemDataContract&gt;))]
  public interface IService
  {
      [OperationContract]
      ItemContainer GetList();
  }
  
  [DataContract]
  [KnownType(typeof(List&lt;ItemDataContract&gt;))]
  public class ItemContainer
  {
      [DataMember]
      public object Data { get; set; }
  }
  
  [DataContract]
  public class ItemDataContract
  {
      [DataMember]
      public string Id { get; set; }
  }
  </code></pre>
  
  <p>And the method's implementation:</p>
  
  <pre><code>public ItemContainer GetList()
  {
      return new ItemContainer
      {
          Data = new List&lt;ItemDataContract&gt; {new ItemDataContract{ Id = "1"}, new ItemDataContract{Id = "2"}
      };
  }
  </code></pre>
  
  <p>On the client's side i have the call to the method:</p>
  
  <pre><code>Service1 _proxy = new Service1();
  var result = _proxy.GetList();
  return (List&lt;ItemDataContract&gt;)result.Data;
  </code></pre>
  
  <p>the problem is that i get an invalid cast exception on the client's side because the result.Data internally is of type 'object' instead of being a List, even if use the serviceKnowntype and knownType. </p>
  
  <p>How do I make this cast possible?</p>