M
michelqa
I'm having hard time trying to serialize the object
System.Windows.Forms.Control with 1.X net framework.
For now my latest "guess" look like this :
//...
using System.Xml.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization;
Control ctl;
int Handle=666666; // a button control handle (button1)
ctl = Control.FromHandle(Handle);
XmlSerializer ser = new XmlSerializer(ctl.GetType()); //*** ERROR
HERE***//
System.Text.StringBuilder sb = new System.Text.StringBuilder();
System.IO.StringWriter writer = new System.IO.StringWriter(sb);
ser.Serialize(writer, ctl);
XmlDocument xdoc = new XmlDocument();
xdoc.LoadXml(sb.ToString());
xdoc.Save("SerializedControl.xml");
But it return the following error :
There was an error reflecting 'System.Windows.Forms.Button'
at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping
(Type type, XmlRootAttribute root, String defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type)
at ...blablabla
I want to serialize System.Windows.Forms.Control to a file in an xml
file or in a file in binary format. I really need help on this
Thanks
System.Windows.Forms.Control with 1.X net framework.
For now my latest "guess" look like this :
//...
using System.Xml.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization;
Control ctl;
int Handle=666666; // a button control handle (button1)
ctl = Control.FromHandle(Handle);
XmlSerializer ser = new XmlSerializer(ctl.GetType()); //*** ERROR
HERE***//
System.Text.StringBuilder sb = new System.Text.StringBuilder();
System.IO.StringWriter writer = new System.IO.StringWriter(sb);
ser.Serialize(writer, ctl);
XmlDocument xdoc = new XmlDocument();
xdoc.LoadXml(sb.ToString());
xdoc.Save("SerializedControl.xml");
But it return the following error :
There was an error reflecting 'System.Windows.Forms.Button'
at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping
(Type type, XmlRootAttribute root, String defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type)
at ...blablabla
I want to serialize System.Windows.Forms.Control to a file in an xml
file or in a file in binary format. I really need help on this

Thanks