[Mono-list] XmlSerializer Deserialize problem

Lluis Sanchez lluis@ximian.com
Thu, 05 Feb 2004 01:16:43 +0100


Hi

On dc, 2004-02-04 at 23:59, Kieren Drapala (TSW) wrote:
> Hello,
> 
> I am having trouble deserialising XML with a dataset class generated by MS
> XSD.exe from a simple schema.
> 
> Here is the main part of the code:
> 
> XmlSerializer serializer = new XmlSerializer(typeof(GetBillerResponse.OFX));
> //GetBillerResponse.OFX was a dataset class generated by MS XSD.exe
> System.IO.StringReader xmlSR = new System.IO.StringReader(lcContents); 
> // lcContents is a string that contains the XML
> GetBillerResponse.OFX po = (GetBillerResponse.OFX)
> serializer.Deserialize(xmlSR); // <-- failing here
> 
> The Error:
> System.Xml.Schema.XmlSchemaException: XmlSchema error: The root element must
> be schema
> in <0x0024f> System.Xml.Schema.XmlSchema:Read
> (System.Xml.XmlReader,System.Xml.Schema.ValidationEventHandler)
> in <0x00073> System.Data.XmlSchemaMapper:Read (System.Xml.XmlReader)
> in <0x00043> System.Data.DataSet:ReadXmlSchema (System.Xml.XmlReader)
> in <0x00042>
> System.Data.DataSet:System.Xml.Serialization.IXmlSerializable.ReadXml
> (System.Xml.XmlReader)
> in <0x00045>
> System.Xml.Serialization.XmlSerializationReader:ReadSerializable
> (System.Xml.Serialization.IXmlSerializable)
> in <0x0016b>
> System.Xml.Serialization.XmlSerializationReaderInterpreter:ReadXmlSerializab
> leElement (System.Xml.Serialization.XmlTypeMapping,bool)
> in <0x00104>
> System.Xml.Serialization.XmlSerializationReaderInterpreter:ReadObject
> (System.Xml.Serialization.XmlTypeMapping,bool,bool)
> in <0x000a2>
> System.Xml.Serialization.XmlSerializationReaderInterpreter:ReadObject ()
> in <0x00075> System.Xml.Serialization.XmlSerializer:Deserialize
> (System.Xml.Serialization.XmlSerializationReader)
> in <0x00068> System.Xml.Serialization.XmlSerializer:Deserialize
> (System.Xml.XmlReader)
> in <0x0003f> System.Xml.Serialization.XmlSerializer:Deserialize
> (System.IO.TextReader)
> 
> 
> I have read articles about 'Locale' problem etc early last year.
> 
> Questions:
> 1. Is this a simple mistake on my behalf ?
> 

This seems to be a bug in DataSet serialization. Can you file a bug
report in bugzila with the test case?

> 2. I don't really want to do anything with the schema functions at this
> stage in my process, how can I not use these (reference to stack trace and
> calls to 'Schema' functions)  ?

XmlSerializer needs to write the DataSet schema together with its data,
so it can reconstruct it when it is deserialized (the schema contains
information about the tables, columns, relations and so on).

Lluis.

> 
> Please advise, thanks in advance, regards, 
> 
> Kieren Drapala
> Analyst / Programmer
> The System Works Pty Ltd
> 
> 
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list