关于集合类的三个简单的序列化问题 [英] Three simple serialization questions about collection classes

查看:54
本文介绍了关于集合类的三个简单的序列化问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我转换了一个先前从ArrayList派生的类(称为"Players"),现在从Dictionary派生。当我尝试反序列化它时,我收到了运行时错误:"未找到"CMC1.Players"类型的对象反序列化的构造函数"

我能够修复这通过添加一个调用基类的伪构造函数:

公共玩家(SerializationInfo serInfo,StreamingContext serContext)
:base(serInfo,serContext)
{

}

但我有3个问题:

1.为什么这需要Dictionary而不是ArrayList?
2. Microsoft是否记录了哪些类需要这个?
3.为什么在反序列化期间发生错误而不是原始序列化?

解决方案

你可以通过以下链接

http ://social.msdn.microsoft.com/Forums/en-US/netfxremo廷/线程/ b8fdabdf-C05B-4d08-bf99-505992875c83


Recently I converted a class (called "Players") that was previously derived from ArrayList to now be derived from Dictionary.    When I tried to deserialize it I got the runtime error:  "The constructor to deserialize an object of type 'CMC1.Players' was not found "

I was able to fix this by adding a dummy constructor that calls the base class:

        public Players(SerializationInfo serInfo, StreamingContext serContext)
          : base(serInfo, serContext)      
        {

        }

But I have 3 questions:

1.  Why is this required for Dictionary but not ArrayList?
2.  Does Microsoft document which classes require this?
3.  Why did the error occur during DEserialization but not the original serialization?

解决方案

Can you plz go through the following link

http://social.msdn.microsoft.com/Forums/en-US/netfxremoting/thread/b8fdabdf-c05b-4d08-bf99-505992875c83


这篇关于关于集合类的三个简单的序列化问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆