I found an answer how to fix it by doing my own serialization. I have
translated it from C++/CLI (C++.NET) into C# and but only tested with
C++.NET (remember the right namespaces!!!!!)
List<int> l;
for (int x=0; x< 10; x++)
l.Add (x);
Serialize:
Stream s = new FileStream("foo.soap", FileMode.Create,
FileAccess.Write, FileShare.None);
SoapFormatter sf = new SoapFormatter();
sf.Serialize(s, l.ToArray() );
s.Close();
Deserialize:
Stream s = new FileStream("foo.soap", FileMode.Open, FileAccess.Read,
FileShare.None);
SoapFormatter sf = new SoapFormatter();
int[] tmp = (int[])(sf.Deserialize(s));
l = new List<int>((System::Collections::Generic::IEnumerab le<int>)
tmp);
s->Close();
A generic List<int> inside an object:
[Serializable]
public class Test: ISerializable
{
public List<int> l_ = new List<int>;
public Test() {
for (int i = 9; i>= 0; --i)
{
l_.Add(i);
}
}
internal Test(SerializationInfo si, StreamingContext context) {
int[] tmp = int[](si.GetValue("l_", typeof(int[]) ));
l_ = new
List<int>((System::Collections::Generic::IEnumerab le<int>) tmp);
}
public void GetObjectData( SerializationInfo info, StreamingContext
/*context*/ )
{
//SerializationInfo - essentially a property bag
info.AddValue("l_", l_.ToArray(), typeof(int[]));
Type t = this.GetType();
info.AddValue("TypeObj", t);
}
}