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

101 строка
3.6 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="016444.html">
<LINK REL="Next" HREF="016387.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>Mon, 13 Oct 2003 23:58:22 -0500</I>
<P><UL>
<LI> Previous message: <A HREF="016444.html">[Mono-list] Building fron CVS
</A></li>
<LI> Next message: <A HREF="016387.html">[Mono-list] Xml Deserialize + Constructor Needed
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#16381">[ date ]</a>
<a href="thread.html#16381">[ thread ]</a>
<a href="subject.html#16381">[ subject ]</a>
<a href="author.html#16381">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>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(&quot;test&quot;);
XmlSerialize mySerializer = new XmlSerializer(typeof(Accounts));
FileStream myFileStream = new FileStream(&quot;.mbloggyrc&quot;, 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
in &lt;0x00144&gt; System.Activator:CreateInstance (System.Type,bool)
in &lt;0x00012&gt; System.Activator:CreateInstance (System.Type)
in &lt;0x001ab&gt;
System.Xml.Serialization.XmlSerializationReaderInterpreter:ReadClassInstance (System.Xml.Serialization.XmlTypeMapping,bool,bool)
in &lt;0x00067&gt;
System.Xml.Serialization.XmlSerializationReaderInterpreter:ReadObject
(System.Xml.Serialization.XmlTypeMapping,bool,bool)
in &lt;0x000a2&gt;
System.Xml.Serialization.XmlSerializationReaderInterpreter:ReadObject ()
in &lt;0x00075&gt; System.Xml.Serialization.XmlSerializer:Deserialize
(System.Xml.Serialization.XmlSerializationReader)
in &lt;0x00068&gt; System.Xml.Serialization.XmlSerializer:Deserialize
(System.Xml.XmlReader)
in &lt;0x0003f&gt; System.Xml.Serialization.XmlSerializer:Deserialize
(System.IO.Stream)
in &lt;0x0009a&gt; .testing:Desarmar ()
in &lt;0x0012c&gt; .testing:Main ()
A Default Constructor.. for what? I have a Constructor for each
element..
Thanks!
Pablo
--
Pablo Fischer Sandoval (pablo [arroba/at] pablo.com.mx)
<A HREF="http://www.pablo.com.mx">http://www.pablo.com.mx</A>
<A HREF="http://www.debianmexico.org">http://www.debianmexico.org</A>
GPG FingerTip: 3D49 4CB8 8951 F2CA 8131 AF7C D1B9 1FB9 6B11 810C
Firma URL: <A HREF="http://www.pablo.com.mx/firmagpg.txt">http://www.pablo.com.mx/firmagpg.txt</A>
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI> Previous message: <A HREF="016444.html">[Mono-list] Building fron CVS
</A></li>
<LI> Next message: <A HREF="016387.html">[Mono-list] Xml Deserialize + Constructor Needed
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#16381">[ date ]</a>
<a href="thread.html#16381">[ thread ]</a>
<a href="subject.html#16381">[ subject ]</a>
<a href="author.html#16381">[ author ]</a>
</LI>
</UL>
</body></html>