Serializing controls using XML Serialization

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to serialize forms, controls and user controls using XML
serialization. I am using Xml Overrides to override properties, but this is
very cumbersome and not practical as you know. How do I know if a property
can be serialized using XML serialization or not ?
Any help is appreciated.

Thanks,
Ramesh
 
First of all, you don't need or want to be serializing Windows Forms
Controls as XML. System.Windows.Forms.Control is not XML Serializable.

Second, you should not need to serialize any interface objects, only data.

As for what is serializable as XML:

public fields
public properties with both a Get and a Set accessor
Classes must have an empty Constructor overload

Note that a class does not have to have all XML-Serializable members to be
serializable. The serializable members will be serialized, and others will
not.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

Orange you bland I stopped splaying bananas?
 
Kevin,
THank you for your quick response. Though Controls are not XML-Serializable,
There is a unique requirement in the application that demands xml
serialization of custom controls derived from System.Windows.Forms.Control.
Interfaces like ISite and properties like Font are not XML-serializable so I
am using XML Overrides not to serialize them. But these overrides are to be
created for each and every control and we need to have an advance knowledge
of what properties fail to be xml-serialized.
So before serializing I want to reflect on the control and inspect
properties that can not be xml-serializable if so to introduce
XmlIgnoreAttribute. This will be done before this class is given to
XmlSerializer. I would like to know if there is a way to identify what can be
xml-serializable and what can not be.(or just exlude all interface-based
properties, read-only properties etc, if so where can i get a comprehensive
list ? ).

Thanks,
Ramesh
 
I have no idea.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

It takes a tough man to make a tender chicken salad.
 
Back
Top