c# - 使用 protobuf-net 序列化数据集时出错

标签 c# protobuf-net

我正在尝试使用 protobuf-net 序列化数据集,但出现以下错误:

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

最佳答案

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

关于c# - 使用 protobuf-net 序列化数据集时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4742526/

相关文章:

c# - 异步 protobuf 序列化

protocol-buffers - 杨 vs Protobuf

c# - 字符串属性是否可以具有函数?

c# - 系统测试桌面应用程序

c# - 如何从 C# 中的 TabPage 获取控件?

C# 泛型类型约束

c# - SignalR 客户端未定义

c# - 如何正确地从 WCF DatacontractSerializer 迁移到 Protobuf-net?

c# - Protobuf-Net 错误消息 : No Serializer defined for type: System. 类型

c# - Protobuf.net WCF 反序列化列表<T>