title: The deserializer has no knowlege of any type that maps to this contract
body: <p>I'm trying to serialize and deserialize a tree of Node objects. My abstract "Node" class as well as other abstract and concrete classes that derive from it are defined in my "Informa" project. In addition, I've created a static class in Informa for serialization  / deserialization. </p>
  
  <p>First I'm deconstructing my tree into a flat list of type <strong>Dictionary(guid,Node)</strong> where guid is the unique id of Node.</p>
  
  <p>I am able to serialize all my Nodes with out a problem. But when I try to deserialize I get the following exception.</p>
  
  <blockquote>
    <p>Error in line 1 position 227. Element
    '<a href="http://schemas.microsoft.com/2003/10/Serialization/Arrays:Value" rel="nofollow noreferrer">http://schemas.microsoft.com/2003/10/Serialization/Arrays:Value</a>'
    contains data of the
    'Informa:Building' data contract. The
    deserializer has no knowlege of any
    type that maps to this contract. Add
    the type corresponding to 'Building'
    to the list of known types - for
    example, by usying the
    KnownTypeAttribute or by adding it to
    the list of known types passed to
    DataContract Serializer.</p>
  </blockquote>
  
  <p>All classes that derive from Node, including Building, have the <strong>[KnownType(typeof(type t))]</strong> attribute applied to them. </p>
  
  <p>My serialization and deserialization methods are below:</p>
  
  <pre><code>public static void SerializeProject(Project project, string filePath)
  {
      try
      {
          Dictionary&lt;Guid, Node&gt; nodeDic = DeconstructProject(project);
  
          Stream stream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None);
  
          //serialize
  
          DataContractSerializer ser = new DataContractSerializer(typeof(Dictionary&lt;Guid, Node&gt;),"InformaProject","Informa");
  
          ser.WriteObject(stream,nodeDic);
  
          // Cleanup
          stream.Close();
      }
      catch (Exception e)
      {
          MessageBox.Show("There was a problem serializing " + Path.GetFileName(filePath) + ". \n\nException:" + e.Message, "Doh!", MessageBoxButtons.OK, MessageBoxIcon.Error);
          throw e;
      }
  
  }
  
  
  
  public static Project DeSerializeProject(string filePath)
  {
      try
      {
          Project proj;
  
          // Read the file back into a stream
          Stream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
  
          DataContractSerializer ser = new DataContractSerializer(typeof(Dictionary&lt;Guid, Node&gt;), "InformaProject", "Informa");
  
          Dictionary&lt;Guid, Node&gt; nodeDic = (Dictionary&lt;Guid, Node&gt;)ser.ReadObject(stream);
  
          proj = ReconstructProject(nodeDic);        
  
          // Cleanup
          stream.Close();
  
          return proj;
  
      }
      catch (Exception e)
      {
          MessageBox.Show("There was a problem deserializing " + Path.GetFileName(filePath) + ". \n\nException:" + e.Message, "Doh!", MessageBoxButtons.OK, MessageBoxIcon.Error);
          return null;
      }
  
  }
  </code></pre>