Serialize a object inherited Label control

  • Thread starter Luiz Rafael Fernandes
  • Start date
L

Luiz Rafael Fernandes

Hi...
i try to serialize a object inherited of label control, as follow:

//definition

public class WinLabel : System.Windows.Forms.Label
{
public WinLabel() {}
}

//execution
WinLabel l = new WinLabel();
l.Text="text";
l.Name="name";

XmlSerializer ser = new XmlSerializer(typeof(MO.WinLabel)); //error
happening this line
FileStream fs = File.OpenWrite("c:\\label.xml");
XmlTextWriter x = new XmlTextWriter(fs,System.Text.Encoding.UTF8);
x.Formatting=Formatting.Indented;
try
{
ser.Serialize(x,l);
}
finally
{
fs.Close();
}

But error happening: "An unhandled exception of type
'System.InvalidOperationException' occurred in system.xml.dll"

thank's for any help..

ps.: sorry my bad english...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top