Protobuf-net v2 Custom List object error [closed]
I am trying to serialize/deserialize a List as defined below with protobuf-net v2, and on deserialize I am getting the following exception.
Type is not expected, and no contract can be inferred
In the example below I am using the WithLengthPrefix calls because this is actually going over a network stream, but the problem is reproducible either way.
var mStream = new MemoryStream();
Serializer.SerializeWithLengthPrefix(mStream, testList, PrefixStyle.Fixed32);
mStream.Seek(0, SeekOrigin.Begin);
var nOrders = Serializer.DeserializeWithLengthPrefix
<List<TestObj>>(mStream, PrefixStyle.Fixed32);
With RiskOrder as defined below
[ProtoContract]
public class TestObj
{
[ProtoMember(1)]
public string Key{ get; set; }
[ProtoMember(2)]
public string Val{ get; set; }
}
It appears this could be related to the bug posted at here, but as it has not been confirmed I thought I'd see if anyone else has 开发者_JAVA技巧run into this / has a work around.
Update I forgot to mention this problem only seems to occur if the list has entries in it.
I believe r403 fixed this bug, as I updated to the latest source as opposed to the v2 beta, and it appears to be fixed.
精彩评论