3
我们有声纳报告说,我们项目中的很多类违反了MissingSerializationConstructorRule,但是类和它的基类都没有实现任何Iserializable接口,任何人都不知道为什么?为什么一个类没有实现ISerializable接口违反MissingSerializationConstructorRule
例如声纳说:
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派生的任何子类必须实现特殊的构造函数,否则它们将不能正确反序列化。字典,所以你的孩子应该从它的类。 – LightStriker
啊,谢谢你们,我正在研究IDictionary而不是字典。 –