【发布时间】:2012-10-13 10:22:17
【问题描述】:
我们有声纳报告说我们项目中的许多类违反了MissingSerializationConstructorRule,但是该类及其基类都没有实现任何 Iserializable 接口,有人知道为什么吗?
例如,声纳说:
public class CommentPage : RmdsPublicationPage, ICommentPage
{
*MissingSerializationConstructorRule
The required constructor for ISerializable is not present in this type.*
public CommentPage()
{
this["COMMENTTXT"] = null;
对应的类在哪里
public class CommentPage : RmdsPublicationPage, ICommentPage
{
public CommentPage()
{
// do something
}
public void Update(string comment)
{
//something else
}
}
两个接口也没有实现 ISerializable,即
public class RmdsPublicationPage : Dictionary<string, object>, IRmdsPublicationPage
public interface IRmdsPublicationPage : IDictionary<string, object>, IDisposable
【问题讨论】:
-
ICommentPage怎么样?你还没有发布。 -
任何从 ISerializable 派生的子类都必须实现特殊的构造函数,否则它们将无法正确反序列化。字典可以,你的孩子也应该从中学习。
-
啊,谢谢你们,我在看 IDictionary 而不是字典。
标签: c# serializable