title: protobuf-net Serializing as base class
body: <p>I'd like to use protobuf-net to serialize a derived class as its base class.   In other words, I want the serialization process to discard any indication that the type is derived:</p>
  
  <pre><code>[ProtoContract]
  class Base
  {
      [ProtoMember(1)]
      public string PublicInfo { get; set; }
  }
  
  class Derived : Base
  {
      public string SecretInfo { get; set; }
  }
  
  class Program
  {
      static void Main(string[] args)
      {
          Derived d = new Derived()
          {
              PublicInfo = "public info",
              SecretInfo = "secret info"
          };
          using (var ms = new MemoryStream())
          {
              Serializer.NonGeneric.Serialize(ms, d as Base);
              ms.Seek(0, SeekOrigin.Begin);
              Base deserialized = Serializer.Deserialize&lt;Base&gt;(ms);
              Console.WriteLine("Deserialized type: " + deserialized.GetType());
              Console.WriteLine("Deserialized value: " + deserialized.PublicInfo);
          }
          Console.ReadLine();
      }
  }
  </code></pre>
  
  <p>I'd like the above program to produce </p>
  
  <pre><code> Deserialized type: Base
   Deserialized value: public info
  </code></pre>
  
  <p>but instead I get an exception about "Type is not expected".</p>
  
  <p>If I add <code>[ProtoContract]</code> to <code>Derived</code>, the <code>PublicInfo</code> field isn't set.  And if I also add <code>[ProtoInclude(2, typeof(Derived))]</code> to <code>Base</code> then the deserialized type is <code>Derived</code>, not <code>Base</code> as I want.</p>
  
  <p>What am I missing?  Apologies if I've overlooked an answer somewhere else.  I think I'm asking for something like the opposite of <a href="https://stackoverflow.com/questions/6505471">this question</a>, though I'd rather not have to explicitly add fields via the <code>RuntimeTypeModel</code>.</p>