title: C# protobuf-net serialized object to java
body: <p>So I have a small problem:</p>
  
  <p>A message is sent using MQTT, it consists of a series of serialized objects using protobuf-net in C# (<strong>I can't modify this code</strong>, but I have access to the source). At the other end i receive the serialized objects in Java, the problem is I can't seem to be able to deserialize the objects using protobuf, if anyone ever had this problem and solved it, please help :)</p>
  
  <p>Example of object from C#:</p>
  
  <pre><code>using ProtoBuf;
  
  namespace Concentrator.Services
  {
  [ProtoContract]
  public class MeterID
  {
      private byte[] _id;
  
      [ProtoMember(1)]
      public byte[] ID
      {
          get { return _id; }
          set { _id = value.Length == 16 ? value : null; }
      }
  
      [ProtoMember(2)] public string MeterType;
  }
  }
  </code></pre>
  
  <p>My attempt at recreating the same object in Java (the .proto file):</p>
  
  <pre><code>syntax = "proto2";
  
   package mqtt.entity;
  
   option java_package = "mqtt.entity";
   option java_outer_classname = "ProtoMeter";
   message Meter {
      optional bytes ID = 1;
       optional string MeterType = 2;
    }
  
    message MeterID {
       repeated Meter mid = 1;
   }
  </code></pre>
  
  <p>A solution to this example would be a huge help, Thanks a lot.</p>
  
  <p>The code where the object is deserialized in C#:</p>
  
  <pre><code>var ms = new MemoryStream(data, 7, data.Length - 9)
  var res = Serializer.Deserialize&lt;List&lt;MeterID&gt;&gt;(ms);
  </code></pre>
  
  <p>this works in C#, I'm trying to achieve the same thing in java</p>