[英]Error when serializing dataset with protobuf-net
I am trying to use protobuf-net to serialize a dataset but getting the below error: 我正在尝试使用protobuf-net序列化数据集,但出现以下错误:
Unhandled Exception: System.InvalidOperationException: No suitable Default DataSet encoding found. 未处理的异常:System.InvalidOperationException:未找到合适的默认DataSet编码。 at ProtoBuf.Serializer.ThrowNoEncoder(DataFormat format, Type valueType) at ProtoBuf.Property.PropertyFactory.CreateProperty[T](Type type, DataFormat& format, MemberSerializationOptions options) 在ProtoBuf.Property.PropertyFactory.CreateProperty [T]处的ProtoBuf.Serializer.ThrowNoEncoder(DataFormat格式,类型valueType)(Type type,DataFormat&format,MemberSerializationOptions options)
at ProtoBuf.Property.PropertyFactory.Create[T](MemberInfo member) at ProtoBuf.Serializer`1.Build() 在ProtoBuf.Serializer`1.Build()的ProtoBuf.Property.PropertyFactory.Create [T](MemberInfo成员)处
Below is the code being used 以下是正在使用的代码
[ProtoContract]
public class Packet
{
[ProtoMember(1)]
public DataSet Data { get; set; }
[ProtoMember(2)]
public string Name { get; set; }
[ProtoMember(3)]
public string Description { get; set; }
}
using (var fs = new FileStream("test0.txt", FileMode.Create))
{
Serializer.Serialize(fs, packet);
Console.WriteLine("Total bytes with protobuf-net = " + fs.Length);
}
DataSet
is not really a data-contract, and there is no supported implementation in "v1" (the code available as pre-built dll). DataSet
并不是真正的数据合同,并且在“ v1”中没有受支持的实现(该代码可作为预构建的dll获得)。 I have, however, done some playing in "v2" here that may be of interest, including a range of metrics for comparison / decision-making. 我有,但是,做了一些打在“V2” 这里可能有兴趣,包括一系列指标进行比较/决策。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.