I am trying to use protobuf-net to serialize a dataset but getting the below error:
Unhandled Exception: System.InvalidOperationException: No suitable Default DataSet encoding found. at ProtoBuf.Serializer.ThrowNoEncod开发者_开发问答er(DataFormat format, Type valueType) at ProtoBuf.Property.PropertyFactory.CreateProperty[T](Type type, DataFormat& format, MemberSerializationOptions options)
at ProtoBuf.Property.PropertyFactory.Create[T](MemberInfo member) at ProtoBuf.Serializer`1.Build()
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). I have, however, done some playing in "v2" here that may be of interest, including a range of metrics for comparison / decision-making.
精彩评论