且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

序列化包含字典成员的类

更新时间:2023-02-19 20:30:54

您不能序列化实现 IDictionary 的类.查看此链接.

You can't serialize a class that implements IDictionary. Check out this link.

问:为什么我不能序列化哈希表?

Q: Why can't I serialize hashtables?

A:XmlSerializer 无法处理实现 IDictionary 的类界面.这部分是由于进度限制,部分原因是哈希表没有的事实在 XSD 类型中有一个对应物系统.唯一的解决办法是实现一个自定义的哈希表不实现 IDictionary界面.

A: The XmlSerializer cannot process classes implementing the IDictionary interface. This was partly due to schedule constraints and partly due to the fact that a hashtable does not have a counterpart in the XSD type system. The only solution is to implement a custom hashtable that does not implement the IDictionary interface.

所以我认为您需要为此创建自己的词典版本.检查这个其他问题.

So I think you need to create your own version of the Dictionary for this. Check this other question.