Hi, guys!
I'm unable to serialize an object with empty array using ProtoBuf.
[ProtoContract]
internal class Tst
{
[ProtoMember(1)]
public int ValInt
{
get;
set;
}
[ProtoMember(2)]
public byte[] ArrayData
{
get;
set;
}
[ProtoMember(3)]
public string Str1
{
get;
set;
}
}
-------------------------------
Tst t = new Tst();
t.ValInt = 128;
t.Str1 = "SOme string text value ttt";
t.ArrayData = new byte[]{};
MemoryStream stm = new MemoryStream();
Serializer.Serialize(stm, t);
Console.WriteLine(stm.Length);
Serializer throws exception: "Cannot write a String header until the
String data has been written"
It works fine if ArrayData is a null ref. or a ref to a non-empty
array.
Is there a proper way to pass a empty array?
--
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/protobuf?hl=en.