我们有声纳报告说,我们项目中的许多类都违反了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
最佳答案
Dictionary(TKey, TValue)实现ISerializable
[SerializableAttribute]
[ComVisibleAttribute(false)]
public class Dictionary<TKey, TValue> : IDictionary<TKey, TValue>,
ICollection<KeyValuePair<TKey, TValue>>, IDictionary, ICollection,
IReadOnlyDictionary<TKey, TValue>, IReadOnlyCollection<KeyValuePair<TKey, TValue>>,
IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable, ISerializable,
IDeserializationCallback