[Mono-dev] "Invalid format" message using DataSet.ReadXML with a xs:dateTime column

iguana mono at vokabeln.de
Wed Jun 4 10:58:48 EDT 2008


I created a DataSet table with a DateTime column and saved it into a file
using DataSet.WriteXML. Using the same code, the files created by .NET and
MONO differ because, apparently, MONO saves DateTime values in a different


MONO saves the milliseconds more accurately but seems to be unaware of time
zones. What's worse, however, is that when I create a file with .NET and
then try to read it with MONO I get an "Invalid format" error message: MONO
does not seem to be able to deal with the time zone information "+02:00"
saved by .NET. 

This is the VB code I use (having created a simple form with two buttons
"cmdWriteXML" and "cmdReadXML"): 

Imports System.Data
Public Class Form1
  Private TestFile As String = "C:\Test.xml"

  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
    Dim MyDate As DateTime = CDate("06.06.2008
    Dim TestTable As DataTable = New DataTable("TestTable")
    TestTable.Columns.Add("TestColumn", Type.GetType("System.DateTime"))
    Dim TestRow As DataRow = TestTable.NewRow
    TestRow("TestColumn") = MyDate
    Dim TestDataSet As DataSet = New DataSet("TestDataSet")
    TestDataSet.WriteXml(TestFile, XmlWriteMode.WriteSchema)
  End Sub

  Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
      Dim TestDataSet As DataSet = New DataSet()
      TestDataSet.ReadXml(TestFile, XmlReadMode.ReadSchema)
    Catch ex As Exception
    End Try
  End Sub
End Class

Clicking both Button1 and Button2 in .NET produces "Success".
Clicking both Button1 and Button2 in MONO produces "Success".
Clicking Button1 in MONO and Button2 in .NET produces "Success."
Clicking Button1 in .NET and Button2 in MONO produces "Invalid format."

The file created by this code looks like this: 

<?xml version="1.0" standalone="yes"?>
  <xs:schema id="TestDataSet" xmlns=""
    <xs:element name="TestDataSet" msdata:IsDataSet="true"
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:element name="TestTable">
                <xs:element name="TestColumn" type="xs:dateTime"
minOccurs="0" />
    <TestColumn>   ***DIFFERENT VALUES SEE ABOVE***   </TestColumn>

Is this a bug in MONO? Can it be fixed? 

View this message in context: http://www.nabble.com/%22Invalid-format%22-message-using-DataSet.ReadXML-with-a-xs%3AdateTime-column-tp17648818p17648818.html
Sent from the Mono - Dev mailing list archive at Nabble.com.

More information about the Mono-devel-list mailing list