Custom .NET Serialization doesn't seem to work

后端 未结 2 1050
失恋的感觉
失恋的感觉 2021-01-03 13:31

I am using BinaryFormatter to serialize a collection of objects of class A stored in a System::Collections::Generic::List^.

相关标签:
2条回答
  • 2021-01-03 14:00

    The problem was that any objects referred to within child objects need not have been completely deserialized immediately after a GetValue call. In my case, the generic List had not yet been completely deserialized and so contained only null references. I finally used IDeserializationCallback to execute code after the object graph had been completely deserialized.

    0 讨论(0)
  • 2021-01-03 14:01

    From your description it sounds like the items within your list are possibly non-serializable; if you have control over that class can you verify if it is also tagged as serializable?

    Also, have you tried using an XmlFormatter to be able to visually check the serialized data to see just how it's being built? It might provide some insight into whether the problem is occuring during serialization or deserialization.

    0 讨论(0)
提交回复
热议问题