HOWTO serialize a form and all its controls
I need to serialize a form and all controls that the user placed into. The problem is that the ControlCollection object is marked as not serialized. how i can solve this issue?.
Regards
Here's a brief description of some of what I did in order to serialize a control tree:
- write a custom formatter in order to overcome several shortcomings of the serialization model(s) and nonserializable objects (events in particular).
- write serialization surrogates for all derivations of Control you are using
- write a surrogate for ControlCollection that also registers with the custom formatter to receive an "EndDeserialization" event so that it may insert the desrialized controls back into the control tree AFTER all the controls are deserialized.
- implement ISerializable on all custom controls which in turn calls the surrogates in order to serialize base classes.
Again, this is the 10,000 ft view of what needs to be done. The devil is in the details. This turns out to be a fairly large task to accomplish but you will learn a lot about serialization ;-)
- Ray
- Ray