title: protobuf-net deserializing: "Arithmetic operation resulted in an overflow."
body: <p>I'm using <a href="https://code.google.com/p/protobuf-net/" rel="nofollow">protobuf-net</a> for serializing/deserialzing my models.</p>
  
  <p>My model is rather simple, serialization seems to work all the time, but if I add specific types to my model deserialization later seems to fail.</p>
  
  <p>I get an "Arithmetic operation resulted in an Overflow" exception as soon as I add "int", "long" or "DateTime" to my models.</p>
  
  <p>Model:</p>
  
  <pre><code>[ProtoContract]
  public class MyModel
  {
      [ProtoMember(1)]
      public DateTime Time { get; set; }
  
      [ProtoMember(2)]
      public List&lt;string&gt; SomeList { get; set; }
  
      [ProtoMember(3)]
      public string Key { get; set; }
  
      [ProtoMember(4)]
      public string Value { get; set; }
  }
  </code></pre>
  
  <p>When I remove the "Time" Property it always seems to work.</p>
  
  <p>Exception:</p>
  
  <pre><code> at ProtoBuf.ProtoReader.TryReadUInt64VariantWithoutMoving(UInt64&amp; value) in c:\Dev\protobuf-net\protobuf-net\ProtoReader.cs:line 375
     at ProtoBuf.ProtoReader.ReadInt64() in c:\Dev\protobuf-net\protobuf-net\ProtoReader.cs:line 357
     at ProtoBuf.BclHelpers.ReadTimeSpanTicks(ProtoReader source) in c:\Dev\protobuf-net\protobuf-net\BclHelpers.cs:line 191
     at ProtoBuf.Serializers.DateTimeSerializer.Read(Object value, ProtoReader source) in c:\Dev\protobuf-net\protobuf-net\Serializers\DateTimeSerializer.cs:line 35
     at ProtoBuf.Serializers.PropertyDecorator.Read(Object value, ProtoReader source) in c:\Dev\protobuf-net\protobuf-net\Serializers\PropertyDecorator.cs:line 77
     at ProtoBuf.Serializers.TypeSerializer.Read(Object value, ProtoReader source) in c:\Dev\protobuf-net\protobuf-net\Serializers\TypeSerializer.cs:line 230
     at ProtoBuf.Meta.TypeModel.DeserializeCore(ProtoReader reader, Type type, Object value, Boolean noAutoCreate) in c:\Dev\protobuf-net\protobuf-net\Meta\TypeModel.cs:line 700
     at ProtoBuf.Meta.TypeModel.Deserialize(Stream source, Object value, Type type, SerializationContext context) in c:\Dev\protobuf-net\protobuf-net\Meta\TypeModel.cs:line 589
     at ProtoBuf.Serializer.Deserialize[T](Stream source) in c:\Dev\protobuf-net\protobuf-net\Serializer.cs:line 77
  </code></pre>
  
  <p>Am I doing something wrong?</p>
  
  <p>[EDIT]</p>
  
  <pre><code>private static void Main(string[] args)
          {
              var proto = new SerializeProtoTest();
              var model = new MyModel
                              {
                                  Key = "abc",
                                  SomeList = new List&lt;string&gt; { "cde" },
                                  Time = DateTime.UtcNow,
                                  Value = "something"
                              };
              var s = proto.Serialize(model);
              var d = proto.Deserialize&lt;MyModel&gt;(s);
              Console.ReadKey();
          }
  
          [ProtoContract]
          public class MyModel
          {
              [ProtoMember(3)]
              public string Key { get; set; }
  
              [ProtoMember(2)]
              public List&lt;string&gt; SomeList { get; set; }
  
              [ProtoMember(1)]
              public DateTime Time { get; set; }
  
              [ProtoMember(4)]
              public string Value { get; set; }
          }
  
          public class SerializeProtoTest
          {
              public T Deserialize&lt;T&gt;(string value)
              {
                  using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(value)))
                  {
                      return Serializer.Deserialize&lt;T&gt;(ms);
                  }
              }
  
              public string Serialize&lt;T&gt;(T obj)
              {
                  using (var ms = new MemoryStream())
                  {
                      Serializer.Serialize(ms, obj);
                      var buffer = ms.ToArray();
                      return Encoding.UTF8.GetString(buffer, 0, buffer.Length);
                  }
              }
          }
      }
  </code></pre>