Protobuff序列化System.Numerics.BigInteger

时间:2016-11-15 14:49:35

标签: c# serialization protocol-buffers protobuf-net

代码:

[ProtoMember(11002)]
public BigInteger StartInteger { get; private set; }

抛出异常:

No serializer defined for type: System.Numerics.BigInteger

如何使StartInteger可序列化?

1 个答案:

答案 0 :(得分:1)

通过执行以下操作来解决此问题:

public BigInteger StartInteger { get; private set; }
[ProtoMember(11002, DataFormat = DataFormat.FixedSize)]
private byte[] StartIntegerSerialized
{
    get { return StartInteger.ToByteArray(); }
    set { StartInteger = new BigInteger(value); }
}