title: How can I deserialize an object if I don't know the right type?
body: <p>Well I want to send commands and data between client and server. </p>
  
  <p>I have three projects:</p>
  
  <ul>
  <li>Client</li>
  <li>Server</li>
  <li>Common - here I put common classes and network abstraction layer</li>
  </ul>
  
  <p>I am using following data structures for communications between client and server</p>
  
  <pre><code>public class Packet&lt;T&gt;
  {
          public string Name { get; set; }
          public string From { get; set; }
          public string To { get; set; }
          public PacketType PacketType { get; set; }
          public T Container { get; set; }
  
          public Packet()
          {
          }
  
          public Packet(string name, PacketType packetType, T container)
          {
              Name = name;
              PacketType = packetType;
              Container = container;
          }
      }
  
      public enum PacketType
      {
          Command,
          Data
      }
  </code></pre>
  
  <p>If I need to send information about files I just create a packet with the necessary structure <code>CreatePacket&lt;FilesInfo&gt;(filesInfo)</code> and then serialize it and send it to client\server. </p>
  
  <p>But how I can deserialize data on receiving side? I don't know what is object type the packet is. Is there any other way or library or something to solve my problem? Also I don't want to use WCF because my app should work on machines with .NET 2.0 installed. </p>