title: How do I Serialize/Deserialize multiple same class instances spread across an assembly
body: <p>The following Console window code illustrates my problem of trying to Desrialize multiple same class instances across the same assembly:</p>
  
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
          const string fnam = "MyFile.bin";
          Dummy a = new Dummy();
          Dummy b = a;
  
          Console.WriteLine($"a == b {a == b}"); // true
  
          var formatter = new BinaryFormatter();
          Stream stream = new FileStream(fnam, FileMode.Create, FileAccess.Write, FileShare.None);
          formatter.Serialize(stream, a);
          formatter.Serialize(stream, b);
          stream.Close();
  
          stream = new FileStream(fnam, FileMode.Open, FileAccess.Read, FileShare.Read);
          a = (Dummy)formatter.Deserialize(stream);
          b = (Dummy)formatter.Deserialize(stream);
          stream.Close();
  
          Console.WriteLine($"a == b {a == b}"); // false
  
          File.Delete(fnam);
      }
  }
  [Serializable]
  class Dummy { }
  </code></pre>
  
  <p>To emphasize, I need the duplicate class instances to be Deserialized accordingly.</p>