[Mono-devel-list] XML deserialization - System.FormatException on System.DateTime.ParseExact()

Atsushi Eno atsushi at ximian.com
Thu May 26 12:16:39 EDT 2005


Hello,

> System.Reflection.TargetInvocationException: Exception has been thrown
> by the target of an invocation. ---> System.FormatException: Invalid
> format.
> 
> in <0x000fe> System.DateTime:ParseExact (System.String s,
> System.String[] formats, IFormatProvider fp, DateTimeStyles style)
> 
> in <0x00040> System.DateTime:ParseExact (System.String s, System.String
> format, IFormatProvider fp, DateTimeStyles style)
> 
> in <0x00019> System.DateTime:ParseExact (System.String s, System.String
> format, IFormatProvider fp)
> 
> in <0x0050f>
> Mono.GeneratedSerializers.Literal.GeneratedReader:ReadObject_InventoryPo
> sitionBaseData (Boolean isNullable, Boolean checkType)

> ob. at PublishDate = DateTime.ParseExact (Reader.ReadElementString (),
> "yyyy-MM-dd", CultureInfo.InvariantCulture);
> 
> The problem here is that the datetime in the xml does not, and probably
> never will, match the format (2nd parameter) in the above statement.
> This format does not take into account a time or timezone component i.e.
> 2005-05-26T16:01:36+01:00

Maybe your "PublishedDate" is xs:date, since "yyyy-MM-dd" pattern
is used only for xs:date type. If the type is xs:dateTime, then
XmlConert.ToDateTime() will be used (and it allows many more
patterns). If it is allowed in MS.NET, maybe attached patch will
fix it.

Lluis: maybe you can check the patch sanity?

Atsushi Eno


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: date-time-serialization.patch
Url: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20050527/830f37dc/attachment.pl 


More information about the Mono-devel-list mailing list