[Mono-bugs] [Bug 338705] New: TimeSpan xml Serialization results in InvalidCastException

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Nov 2 11:25:38 EDT 2007


https://bugzilla.novell.com/show_bug.cgi?id=338705

           Summary: TimeSpan xml Serialization results in
                    InvalidCastException
           Product: Mono: Class Libraries
           Version: 1.2
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Sys.XML
        AssignedTo: atsushi at ximian.com
        ReportedBy: daniel at hofmannmail.ath.cx
         QAContact: mono-bugs at ximian.com
          Found By: ---


Created an attachment (id=181813)
 --> (https://bugzilla.novell.com/attachment.cgi?id=181813)
Demonstration of the bug

Although System.TimeSpan isn't serialized as I would expect it neither in
Net2.0 where it seems to be "by Design" nor in Mono, there is a difference in
how they don't serialize a TimeSpan.

Output of the attached program executed on .Net2.0:
--------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-16"?>
<TimeSpan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" />
--------------------------------------------------------------------------------
"Output" of the attached program executed on Rev88668:
--------------------------------------------------------------------------------
Unhandled Exception: System.InvalidOperationException: There was an error
generating the XML document. ---> System.InvalidCastException: Cannot cast from
source type to destination type.
  at System.Xml.Serialization.XmlCustomFormatter.ToXmlString
(System.Xml.Serialization.TypeData type, System.Object value) [0x0025b] in
/home/dani/src/mono/mcs/class/System.XML/System.Xml.Serialization/XmlCustomFormatter.cs:259 
  at System.Xml.Serialization.XmlSerializationWriter.WriteTypedPrimitive
(System.String name, System.String ns, System.Object o, Boolean xsiType)
[0x00084] in
/home/dani/src/mono/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriter.cs:889 
  at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObject
(System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob,
System.String element, System.String namesp, Boolean isNullable, Boolean
needType, Boolean writeWrappingElem) [0x0014f] in
/home/dani/src/mono/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriterInterpreter.cs:135 
  at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteRoot
(System.Object ob) [0x00056] in
/home/dani/src/mono/mcs/class/System.XML/System.Xml.Serialization/XmlSerializationWriterInterpreter.cs:75 
  at System.Xml.Serialization.XmlSerializer.Serialize (System.Object o,
System.Xml.Serialization.XmlSerializationWriter writer) [0x0001c] in
/home/dani/src/mono/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs:408 
  at System.Xml.Serialization.XmlSerializer.Serialize (System.Xml.XmlWriter
writer, System.Object o, System.Xml.Serialization.XmlSerializerNamespaces
namespaces) [0x00064] in
/home/dani/src/mono/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs:469
--- End of inner exception stack trace ---

  at System.Xml.Serialization.XmlSerializer.Serialize (System.Xml.XmlWriter
writer, System.Object o, System.Xml.Serialization.XmlSerializerNamespaces
namespaces) [0x000a0] in
/home/dani/src/mono/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs:476 
  at System.Xml.Serialization.XmlSerializer.Serialize (System.IO.TextWriter
textWriter, System.Object o) [0x0000e] in
/home/dani/src/mono/mcs/class/System.XML/System.Xml.Serialization/XmlSerializer.cs:424 
  at TimeSpanSerializationTest.Main () [0x00016] in
/home/dani/tmp/TimeSpanSerialization.cs:12


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list