title: Using Protobuf-net, I get an exception about an unknown wire-type with List<Subclassable>
body: <p>I've started to convert our Unity/iOS game to save state with Protobuf-net. It looked like things were working OK, until I added this instance variable to <code>GameState</code></p>
  
  <pre><code>[ProtoMember(10)]
  public List&lt;Unit&gt; fUnits;
  </code></pre>
  
  <p>Unit is</p>
  
  <pre><code>[ProtoContract]
  [ProtoInclude(21, typeof(ArtilleryUnit))]
  [ProtoInclude(22, typeof(CavalryArtilleryUnit))]
  [ProtoInclude(23, typeof(CavalryUnit))]
  [ProtoInclude(24, typeof(InfantryUnit))]
  [Serializable]
  public class Unit : IActionHandler
  </code></pre>
  
  <p>This is the first subclass I've serialized. I'm testing my code by deserializing right after writing</p>
  
  <pre><code>using (Stream memoryStream = new MemoryStream()) {
      byte[] data = System.Text.Encoding.UTF8.GetBytes(readText);
      memoryStream.Write(data, 0, data.Length);
      memoryStream.Position = 0;
      WBTSSerializer deserializer = new WBTSSerializer();
  
      testState = new GameState();
      deserializer.Deserialize(memoryStream, testState, typeof(GameState));
  }
  </code></pre>
  
  <p>and I get</p>
  
  <pre><code>ProtoBuf.ProtoException: Invalid wire-type; this usually means you have over-written a file without truncating or setting the length; see http://stackoverflow.com/q/2152978/23354
    at ProtoBuf.ProtoReader.SkipField () [0x00000] in &lt;filename unknown&gt;:0
    at WBTSSerializer.Read (wbts.Unit , ProtoBuf.ProtoReader ) [0x00000] in &lt;filename unknown&gt;:0
    at WBTSSerializer.Read (wbts.GameState , ProtoBuf.ProtoReader ) [0x00000] in &lt;filename unknown&gt;:0
    at WBTSSerializer.Deserialize (Int32 , System.Object , ProtoBuf.ProtoReader ) [0x00000] in &lt;filename unknown&gt;:0
    at ProtoBuf.Meta.TypeModel.DeserializeCore (ProtoBuf.ProtoReader reader, System.Type type, System.Object value, Boolean noAutoCreate) [0x00000] in &lt;filename unknown&gt;:0
    at ProtoBuf.Meta.TypeModel.Deserialize (System.IO.Stream source, System.Object value, System.Type type, ProtoBuf.SerializationContext context) [0x00000] in &lt;filename unknown&gt;:0
    at ProtoBuf.Meta.TypeModel.Deserialize (System.IO.Stream source, System.Object value, System.Type type) [0x00000] in &lt;filename unknown&gt;:0
    at wbts.Game.SaveGame (System.String filename) [0x000c1] in /Users/david/Shenandoah/WBTS/wbts/wbts/Game.cs:620
  </code></pre>
  
  <p>Needless to say, I've checked for overwriting (it's a brand new file). And, if I take out the <code>ProtoMember(10)</code>, it won't throw.</p>
  
  <p>If I take out the <code>ProtoInclude</code> lines, I get an error about the subclasses. And, if I take out <code>ProtoMember</code> within <code>Unit</code>, it still throws.</p>
  
  <p>If it matters, I am currently just running this from Xamarin (on Mac OS X — I'm an iOS developer). But that's just for ease of testing, I have managed to hit Protobuf-net with enough sticks to make it run on an iPad.</p>