[Mono-dev] System.Data.DataSet ReadXml question

Atsushi Eno atsushi at ximian.com
Fri Sep 9 01:17:51 EDT 2005


Hi,

Chris Micacchi wrote:
> I have a program that creates a DataTable with a column of type 
> System.Version, and then writes out the dataset containing the table to 
> an XML file using DataSet.WriteXml().  The resulting file looks fine, 
> but when I then use DataSet.ReadXml() to re-read the data back into the 
> dataset, I get this:
> 
> Unhandled Exception: System.InvalidCastException: Unknown target 
> conversion type
> in <0x0065c> System.Convert:ToType (System.Object value, System.Type 
> conversionType, IFormatProvider provider)
> in <0x00032> System.Convert:ChangeType (System.Object value, System.Type 
> conversionType)
> in <0x0030e> System.Data.XmlDataReader:StringToObject (System.Type type, 
> System.String value)
> in <0x001d3> System.Data.XmlDataReader:ReadElementElement 
> (System.Data.DataRow row)
> ....
> 
> It looks like it's trying to convert the stringified version number back 
> to a System.Version and hitting a brick wall.  Am I doing something 
> wrong here?  I've attached a small sample program that hits this problem 
> for me, in case it helps.  Compile it with
>     mcs datasettest.cs -out:datasettest.exe -r:System.Data

Yes, kinda wrong. System.Version is not documented as a supported
datatype:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/
cpref/html/frlrfsystemdatadatacolumnclassdatatypetopic.asp

My guess is that for such input type that is not listed on the
list shown in above page MS.NET checks whether the type has a
constructor which takes a string.

I'll take care it and possibly fix the code after 1.1.9 release.

Atsushi Eno



More information about the Mono-devel-list mailing list