Suppose I have a class A that contains a class B, and both are [Serializable].
I suggested that when deserializing, class B will first be deserialized.
However, this is not the case, as I could confirm, by simply logging in when all the [OnDeserialized] methods have been deleted.
Now I have the following problem:
After class A is deserialized, it must install itself using the values ββfrom class B. Unfortunately, class B has not yet been deserialized, so classA is not configured correctly.
My problem will be solved if I can get BinaryFormatter to deserialize classB in front of class A or allow the diagram of objects from bottom to top and not top to bottom.
Another obvious solution would be to force classB to fire an event when it is deserialized, and then set class A, but I want to stay away from this not elegant solution.
Therefore, I would appreciate if anyone knows of a better solution.
source
share