簡體   English   中英

使用protobuf-net序列化數據集時出錯

[英]Error when serializing dataset with protobuf-net

我正在嘗試使用protobuf-net序列化數據集,但出現以下錯誤:

未處理的異常:System.InvalidOperationException:未找到合適的默認DataSet編碼。 在ProtoBuf.Property.PropertyFactory.CreateProperty [T]處的ProtoBuf.Serializer.ThrowNoEncoder(DataFormat格式,類型valueType)(Type type,DataFormat&format,MemberSerializationOptions options)
在ProtoBuf.Serializer`1.Build()的ProtoBuf.Property.PropertyFactory.Create [T](MemberInfo成員)處

以下是正在使用的代碼

    [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” 這里可能有興趣,包括一系列指標進行比較/決策。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM