【发布时间】:2012-06-19 01:25:58
【问题描述】:
这个错误:
Data of this type has inbuilt behaviour, and cannot be added to a model in this way: System.Int64
仅在以下行为 protobuf-net 在序列化具有 TimeStamp 类型的对象时使用的 long 代理类型时发生。
RuntimeTypeModel.Default.Add(typeof(TimeStamp),false).SetSurrogate(typeof(long));
TimeStamp 类定义了以下显式运算符:
public static explicit operator TimeStamp( long timeStamp)
{
return new TimeStamp(timeStamp);
}
public static explicit operator long( TimeStamp TimeStamp)
{
return TimeStamp.Internal;
}
那么为什么它不接受 long 作为 TimeStamp 的代理类型呢? 在开始尝试protobuf-net之前,已经手写序列化了 在序列化/反序列化时使用 long 作为 TimeStamp 的代理项。
【问题讨论】:
标签: c# serialization protobuf-net