John,
The problem with the XmlSerializer is that it will only save public
properties, and a good number of those properties are other classes that
when serialized, really don't have the correct context. Ultimately, you
can't serialize everything, because things such as a control handle have no
context.
What I would do is create an object that implements
ISerializationSurrogate, so that you can provide serialization semantics
without having to implement it on the control. This way, you can specify
the properties you want to save, and not have to create different classes
which implement ISerializable.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"John Sutor" <jo********@cinfin.com> wrote in message
news:uL**************@TK2MSFTNGP10.phx.gbl...
Does anyone have a good example of how to serialize a controls
properties?
HEre is my example but is does not work
object mObject = this.textBox1;
Debug.WriteLine(mObject.GetType());
XmlSerializer formatter = new XmlSerializer(mObject.GetType());
Stream stream = new FileStream("serialTest.xml",FileMode.Create,
FileAccess.Write,FileShare.None);
formatter.Serialize(stream,mObject);
stream.Close();
John S
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!