I am using BinaryFormatter
to serialize a collection of objects of class A
stored in a System::Collections::Generic::List<A^>^
. I have added the [Serializable]
tag and have implemented ISerializable
in class A
(both GetObjectData
and the special constructor). When deserializing, I find that the list is deserialized and contains the same number of elements as was serialized. However, each of these elements is a null reference.
I've checked for thrown exceptions and am sure that it is not the case. I have checked to ensure that the special constructor of the form A(SerializationInfo ^info, StreamingContext context)
is called the correct number of times during deserialization but these re-constructed objects are not being referenced from the deserialized collection.
I also replaced the System::Collections::Generic::List<A^>^
with array<A^>^
and I'm still getting the same results. The array has the correct number of elements but each element is a null reference.
Anyone who has seen a similar problem? Any clues?