The simple class below inherits from HashSet and thus has to implement the ISerialization members (in a non standard way). I get the following Exception when I try to serialize then deserialize an instance of Group:
Test method UtilitiesTests.GroupTest.SerializeTest threw exception: System.Reflection.TargetInvocationException: Het doel van een aanroep heeft een uitzondering veroorzaakt. ---> System.Runtime.Serialization.SerializationException: Lid nameprop is niet gevonden..
Unfortunately this is in dutch. It means that the member "nameprop" could not be found! What is wrong??
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; }
}
}