【问题标题】:Does protobuf-net support System.Collections.Queue?protobuf-net 是否支持 System.Collections.Queue?
【发布时间】:2012-09-16 05:38:57
【问题描述】:

我使用 protobuf-net 而不是 binaryformatter 运行我的客户端/服务器应用程序,我得到下一个异常:“没有为类型定义序列化程序:System.Collections.Queue”。 我不完全确定,可能是我做错了什么的原因...... 因为我已经询问过 Dictionary/List 并且支持这些类型(Can I serialize an object (containing members: Dictionary, List... etc) in Mono and deserialize it in MS.NET or vice versa by using protobuf-net?)。

我刚刚读到:http://code.google.com/p/protobuf-net/wiki/GettingStarted "支持: 任何实现 IEnumerable 并具有 Add(T) 方法的类型 " 并且队列 @9​​87654323@ 没有 Add(T)...

问题: 但我想完全确定。 protobuf-net 是否支持 System.Collections.Queue

【问题讨论】:

    标签: c# .net protobuf-net


    【解决方案1】:

    在当前时间,不:它没有。为了序列化的目的,我建议将数据视为列表。作为参考,XmlSerializer 也讨厌它 - 这是Queue<string>XmlSerializer 输出:

    “您必须在 System.Collections.Generic.Queue`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] 上实现默认访问器,因为它继承自 ICollection。”

    【讨论】:

    • 问题似乎是关于非通用Queue,而不是通用Queue<T>
    • @svick 同样适用,不过;除了另外对于非泛型类型,我们还需要告诉它我们应该期待什么项目类型
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-13
    • 2021-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多