以下测试失败并出现此错误:
“System.InvalidOperationException:找不到合适的默认 IB 编码。”
[ProtoContract]
public class A
{
[ProtoMember(1)]
public IB B { get; set; }
}
public interface IB
{
}
[ProtoContract]
public class B : IB
{
[ProtoMember(1)]
public int SomeProperty { get; set; }
}
[TestFixture]
public class TestFixture
{
[Test]
public void Test()
{
var a = new A {B = new B()};
using (var m = new MemoryStream())
{
Serializer.Serialize(m, a);
}
}
}
我正在使用 Protobuf.net 的这个实现:
http://code.google.com/p/protobuf-net/
我错过了什么?非常感谢你。