[Mono-list] Xml Deserialize + Constructor Needed

Lluis Sanchez lluis@ximian.com
Tue, 14 Oct 2003 10:28:47 +0200


On dt, 2003-10-14 at 06:58, Pablo Fischer wrote:
> Hi all!
> 
> I created a file in XML with the help of XmlSerialization, how I want to
> Deserialize it, I found in may sites (also in msdn) a simple way to do
> this, so my method:
> 
> private static void Desarmar() {
>  Accounts accs = new Accounts("test");
>  XmlSerialize mySerializer = new XmlSerializer(typeof(Accounts));
>  FileStream myFileStream = new FileStream(".mbloggyrc", FileMode.Open);
>  accs = (Accounts)mySerializer.Deserialize(myFileStream);
> }
> 
> It compiles ok, but when I run it I get:
> 
> Unhandled Exception: System.MissingMethodException: Default constructor
> not found
> (snip)
> in <0x0009a> .testing:Desarmar ()
> in <0x0012c> .testing:Main ()
> 
> A Default Constructor.. for what? I have a Constructor for each
> element..

A default constructor for Accounts. XmlSerializer will create the
Accounts instance for you, you don't need to create it yourself.

Lluis.

> 
> Thanks!
> Pablo