mail-archives/mono-list/2003-October/016400.html

95 строки
3.4 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE> [Mono-list] Xml Deserialize + Constructor Needed
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:pablo%40pablo.com.mx">
<META NAME="robots" CONTENT="index,nofollow">
<LINK REL="Previous" HREF="016387.html">
<LINK REL="Next" HREF="016383.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Mono-list] Xml Deserialize + Constructor Needed
</H1>
<B>Pablo Fischer
</B>
<A HREF="mailto:pablo%40pablo.com.mx"
TITLE="[Mono-list] Xml Deserialize + Constructor Needed">pablo@pablo.com.mx
</A><BR>
<I>Tue, 14 Oct 2003 11:25:02 -0500</I>
<P><UL>
<LI> Previous message: <A HREF="016387.html">[Mono-list] Xml Deserialize + Constructor Needed
</A></li>
<LI> Next message: <A HREF="016383.html">[Mono-list] Dispose() method in the UdpClient class
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#16400">[ date ]</a>
<a href="thread.html#16400">[ thread ]</a>
<a href="subject.html#16400">[ subject ]</a>
<a href="author.html#16400">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>Thanks! It works!
Also thanks to Rafael.
Pablo
El mar, 14-10-2003 a las 03:28, Lluis Sanchez escribió:
&gt;<i> On dt, 2003-10-14 at 06:58, Pablo Fischer wrote:
</I>&gt;<i> &gt; Hi all!
</I>&gt;<i> &gt;
</I>&gt;<i> &gt; I created a file in XML with the help of XmlSerialization, how I want to
</I>&gt;<i> &gt; Deserialize it, I found in may sites (also in msdn) a simple way to do
</I>&gt;<i> &gt; this, so my method:
</I>&gt;<i> &gt;
</I>&gt;<i> &gt; private static void Desarmar() {
</I>&gt;<i> &gt; Accounts accs = new Accounts(&quot;test&quot;);
</I>&gt;<i> &gt; XmlSerialize mySerializer = new XmlSerializer(typeof(Accounts));
</I>&gt;<i> &gt; FileStream myFileStream = new FileStream(&quot;.mbloggyrc&quot;, FileMode.Open);
</I>&gt;<i> &gt; accs = (Accounts)mySerializer.Deserialize(myFileStream);
</I>&gt;<i> &gt; }
</I>&gt;<i> &gt;
</I>&gt;<i> &gt; It compiles ok, but when I run it I get:
</I>&gt;<i> &gt;
</I>&gt;<i> &gt; Unhandled Exception: System.MissingMethodException: Default constructor
</I>&gt;<i> &gt; not found
</I>&gt;<i> &gt; (snip)
</I>&gt;<i> &gt; in &lt;0x0009a&gt; .testing:Desarmar ()
</I>&gt;<i> &gt; in &lt;0x0012c&gt; .testing:Main ()
</I>&gt;<i> &gt;
</I>&gt;<i> &gt; A Default Constructor.. for what? I have a Constructor for each
</I>&gt;<i> &gt; element..
</I>&gt;<i>
</I>&gt;<i> A default constructor for Accounts. XmlSerializer will create the
</I>&gt;<i> Accounts instance for you, you don't need to create it yourself.
</I>&gt;<i>
</I>&gt;<i> Lluis.
</I>&gt;<i>
</I>&gt;<i> &gt;
</I>&gt;<i> &gt; Thanks!
</I>&gt;<i> &gt; Pablo
</I>&gt;<i>
</I>
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI> Previous message: <A HREF="016387.html">[Mono-list] Xml Deserialize + Constructor Needed
</A></li>
<LI> Next message: <A HREF="016383.html">[Mono-list] Dispose() method in the UdpClient class
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#16400">[ date ]</a>
<a href="thread.html#16400">[ thread ]</a>
<a href="subject.html#16400">[ subject ]</a>
<a href="author.html#16400">[ author ]</a>
</LI>
</UL>
</body></html>