C# 请给我解释一下这个例外

C# 请给我解释一下这个例外,c#,.net,serialization,C#,.net,Serialization,下面的简单类继承自HashSet,因此必须(以非标准方式)实现ISerialization成员。尝试序列化然后反序列化组的实例时,出现以下异常: 试验方法 UtilitiesTests.GroupTest.SerializeTest 引发异常: System.Reflection.TargetInvocationException: 他是多尔·范恩·安罗普·希夫特 uitzondering veroorzaakt。--> System.Runtime.Serialization.Serializ

下面的简单类继承自HashSet,因此必须(以非标准方式)实现ISerialization成员。尝试序列化然后反序列化组的实例时,出现以下异常:

试验方法 UtilitiesTests.GroupTest.SerializeTest 引发异常: System.Reflection.TargetInvocationException: 他是多尔·范恩·安罗普·希夫特 uitzondering veroorzaakt。--> System.Runtime.Serialization.SerializationException: 盖子名称为niet gevonden

不幸的是,这是荷兰语。这意味着找不到成员“nameprop”! 怎么了

using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace Grouping
{
    [Serializable]
    public class Group<T> : HashSet<T>
    {
        public Group(string name)
        {
            Name = name;
        }

        protected Group(){}

        protected Group(SerializationInfo info, StreamingContext context):base(info,context)
        {
            Name = info.GetString("nameprop");
        }

        protected new void GetObjectData(SerializationInfo info,StreamingContext context)
        {
            base.GetObjectData(info,context);
            info.AddValue("nameprop", Name);
        }

        public string Name { get; private set; }
    }
}
使用系统;
使用System.Collections.Generic;
使用System.Runtime.Serialization;
名称空间分组
{
[可序列化]
公共类组:HashSet
{
公共组(字符串名称)
{
名称=名称;
}
受保护组(){}
受保护组(SerializationInfo,StreamingContext上下文):基本(信息,上下文)
{
Name=info.GetString(“nameprop”);
}
受保护的新void GetObjectData(SerializationInfo信息、StreamingContext上下文)
{
base.GetObjectData(信息、上下文);
信息添加值(“名称属性”,名称);
}
公共字符串名称{get;private set;}
}
}

您的
GetObjectData
方法在序列化过程中永远不会被调用,因为您不重写父方法,而是对其进行阴影处理。您应该使用
override
而不是
new

谢谢!就这样。。。你能给我指出英文的错误信息吗,这样其他像我这样的傻瓜就更容易找到这个问题了?我不知道,因为我实际上并没有运行代码,只是看了看:)如果你需要超越错误,请从中签出这个注释。未找到SerializationException成员