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

Hickey, Damian (Exchange) DHickey at Bear.com
Tue May 31 12:49:30 EDT 2005


Am away from this evening for a few days, so will do when I get back.

- Damian

-----Original Message-----
From: Lluis Sanchez [mailto:lluis at ximian.com] 
Sent: Monday, May 30, 2005 8:43 AM
To: Hickey, Damian (Exchange)
Cc: mono-devel-list at lists.ximian.com
Subject: Re: [Mono-devel-list] XML deserialization -
System.FormatExceptionon System.DateTime.ParseExact()

Hi,

Can you please file a bug report in bugzilla.ximian.com, attaching a
simple test application that can be used to reproduce the issue?

The solution will be to be compatible with MS.NET, even if that means
not being fully compatible with the specs.

Lluis.

On dj, 2005-05-26 at 16:05 +0100, Hickey, Damian (Exchange) wrote:
> Hi All,
> 
>  
> 
> This is my first foray into the land of Mono after a few years on
> MS .Net. and am very happy with the level of compatibility. I've just
> subbed to this mailing list, so if I break any rules do let me know...
> 
>  
> 
> I'm having a problem with XML deserialization and am wondering if it's
> a bug related to 71290 (http://bugzilla.ximian.com/show_bug.cgi?
> id=71290) or not and if anyone can help? The code works under MS.Net
> 1.1, but not Mono 1.1.7 (on Windows XP).
> 
>  
> 
> So I have this simple piece of xml:
> 
>  
> 
> <InventoryPositionBase
> xmlns="urn:company.com:Application.Messages:v1.0">
> 
>   <ProductId>9496</ProductId>
> 
>   <PortfolioId>175</PortfolioId>
> 
>   <PublishDate>2005-05-25-04:00</PublishDate>
> 
> </InventoryPositionBase>
> 
>  
> 
> And during deserialization the following exception is thrown:
> 
>  
> 
> 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)
> 
> in <0x00086>
>
Mono.GeneratedSerializers.Literal.GeneratedReader:ReadRoot_InventoryPosi
tionBaseData ()
> 
> in <0x00000> <unknown method>
> 
> in (wrapper managed-to-native)
> System.Reflection.MonoMethod:InternalInvoke (object,object[])
> 
> in <0x0006f> System.Reflection.MonoMethod:Invoke (System.Object obj,
> BindingFlags invokeAttr, System.Reflection.Binder binder ,
> System.Object[] parameters, System.Globalization.CultureInfo culture)
> 
> --- End of inner exception stack trace ---
> 
> in <0x00104> System.Reflection.MonoMethod:Invoke (System.Object obj,
> BindingFlags invokeAttr, System.Reflection.Binder binder,
> System.Object[] parameters, System.Globalization.CultureInfo culture)
> 
> in <0x00017> System.Reflection.MethodBase:Invoke (System.Object obj,
> System.Object[] parameters)
> 
> in <0x00073> System.Xml.Serialization.XmlSerializer:Deserialize
> (System.Xml.Serialization.XmlSerializationReader reader)
> 
> in <0x0004a> System.Xml.Serialization.XmlSerializer:Deserialize
> (System.Xml.XmlReader xmlReader)
> 
> in <0x0003c> System.Xml.Serialization.XmlSerializer:Deserialize
> (System.IO.TextReader textReader)
> 
> in <0x00091> Messages.Utility:Deserialize (System.Byte[] msg,
> System.Type type)
> 
> in <0x0009c> ...
> 
>  
> 
> I managed to grab the emitted code that performs the xml to object
> parsing and it looks like the problem occurs when parsing the
> <PublishDate> element during the ReadObject_InventoryPositionBaseData
> method.  The offending line of code:
> 
>  
> 
> 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
> 
>  
> 
> Is this a bug or have I done something completely wrong?
> 
>  
> 
> Help and ideas appreciated.
> 
>  
> 
> All the best,
> 
>  
> 
> Damian
> 
> 
> fitxer adjunt Document de text pla (Disclaimer.txt)
> 
> **********************************************************************
> Please be aware that, notwithstanding the fact that the person sending
> this communication has an address in Bear Stearns' e-mail system, this
> person is not an employee, agent or representative of Bear Stearns.
> Accordingly, this person has no power or authority to represent, make
> any recommendation, solicitation, offer or statements or disclose
> information on behalf of or in any way bind Bear Stearns or any of its
> affiliates.
> **********************************************************************
> 
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list




**********************************************************************
Please be aware that, notwithstanding the fact that the person sending
this communication has an address in Bear Stearns' e-mail system, this
person is not an employee, agent or representative of Bear Stearns.
Accordingly, this person has no power or authority to represent, make
any recommendation, solicitation, offer or statements or disclose
information on behalf of or in any way bind Bear Stearns or any of its
affiliates.
**********************************************************************




More information about the Mono-devel-list mailing list