开发者

Protobuf-net v2 Custom List object error [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 11 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜