 |
XML deserialization error
[reply]
|
09/28/04 05:33 AM EST posted by Blearns email web |
|
I am currently getting an error on deserialization of XML by .NET that was serialized by the same .NET: Event Type: Error
Event Source: Doceus.Console
Event Category: None
Event ID: 0
Date: 9/24/2004
Time: 1:49:44 PM
User: N/A
Computer: CRANE
Description: Unable to load Tasks.config: There is an
error in XML document (11, 6).; System.Xml.InnerException: Ticks must be between
DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks.Parameter name:
ticks; mscorlib]
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
If .NET wrote out the ticks, shouldn't it be able to consume the same ticks? Any ideas? |
|
|
|
| What is it trying to actually serialize, is it outside of the min/max value? Perhaps it can write outside of that value but not read it? What happens if you remove that item from the object you are serializing? Can you do that? hrm? |
|
|
|
The item it is actually trying to serialize and deserialize is a DateTime that has been set to DateTime.MinValue (or whatever it's really called).
If I use something else, it works fine, but I'd really like to use a DateTime. |
|
|
|
| Have you reviewed the XML to see what values it's actually using? Is DateTime.MinValue.Ticks = 0? |
|
|
|
| I've had problems with Min and Max value in .NET for a while. Try the default to DateTime.MinValue.AddDays(1) and see if it works. If that works, the issue is simply that .NET cannot deserialize something if it is equal to the minvalue since this obviously isn't allowed... wait, it um, nah... wait, I guess it could be a bug in .NET, but .NET doesn't have bugs. Hrm. |
|
|
|
The DateTime that it serializes is equal to "0001-01-01T00:15:00.0000000-05:00"
My guess is that .NET is stupid and writes the -5 GMT because that's where we are, and then on deserialization it tries to load up MinValue minus five hours.
This seems sooooo weak to me, and I've resisted the kludge of adding 5 hours, hoping that someone, somewhere had the "real fix". |
|
|
|
| Set the server's time to GMT? |
|
|
|
My lame solution, which works, is to break up all DateTimes. To [XmlIgnore()] them and then provide broken up properties, the first a DateTime with [XmlElementAttribute(DataType="date")] which removes all time data, and then the time as Hour, Minute, and Second each an int.
I think it's a crappy thing to have to do, but it works like a charm (so far). |
|
|
|
| It may be clugey, but at least it works. I've been looking around on Google for this and am shocked that I haven't seen a single complaint about it so far. |
|
[reply]
|
06/01/05 10:45 PM EST posted by Squash |
|
Could this be related to SP4? One of our machines has SP4 plus a whole
lot of hotfixes and it is displaying this error. Our other computers
aren't displaying this error.
|
|