2011-01-20 63 views
2

我想使用protobuf网序列化数据集,但提示以下错误:数据集时:错误序列化与protobuf网

Unhandled Exception: System.InvalidOperationException: No suitable Default DataSet encoding found. at ProtoBuf.Serializer.ThrowNoEncoder(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()

下面是正在使用的代码

[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); 
    } 

回答

1

DataSet不是真的是数据合同,并且“v1”(代码可用作预构建的dll)中没有支持的实现。然而,我已经在“v2”here中玩过一些可能感兴趣的游戏,其中包括一系列用于比较/决策的指标。