我正在尝试使用ProtoBuf-Net r668对包含在DynamicType = true的几个图层中的对象进行反序列化。
使用旧版本的ProtoBuf-Net(v1),它会反复序列化而不会出现问题。但是,使用最新版本时,它会失败
ProtoBuf.ProtoException:内部错误;发生了关键的不匹配
[ProtoContract]
private class A
{
[ProtoMember(1, DynamicType = true)]
public object Body { get; set; }
}
[ProtoContract]
private class B
{
[ProtoMember(1, DynamicType = true)]
public object Body { get; set; }
}
[ProtoContract]
private class C
{
[ProtoMember(1)]
public string Name { get; set; }
}
[Test]
public void Try_Serialize_Nested_DynamicTypes()
{
var obj = new A() {Body = new B() {Body = new C() {Name = "Brian"}}};
var serializer = new ProtoBufSerializer();
var results = serializer.Serialize(obj);
var g = serializer.Deserialize<A>(results);
}