Shiny Donkey!
Shiny Donkey! Shiny Donkey! Shiny Donkey!
                  Fake Banner Ads!  Mini-Sites!  
    New Shiny Donkey Posts  more >>
* BREAKING NEWS *  9 out of 10 Amish web developers recommend "the reefer" instead of shinydonkey.com

.NET 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?

 


[reply]   

09/28/04 06:20 AM EST
posted by alex email

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?

 


[reply]   

09/28/04 06:42 AM EST
posted by Blearns email web

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.

 


[reply]   

09/28/04 06:49 AM EST
posted by JER email web

Have you reviewed the XML to see what values it's actually using? Is DateTime.MinValue.Ticks = 0?

 


[reply]   

09/28/04 06:50 AM EST
posted by alex email

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.

 


[reply]   

09/28/04 07:02 AM EST
posted by Blearns email web

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".

 


[reply]   

09/28/04 07:09 AM EST
posted by alex email

Set the server's time to GMT?

 


[reply]   

09/28/04 10:42 AM EST
posted by Blearns email web

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).

 


[reply]   

09/28/04 10:49 AM EST
posted by JER email web

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.

 

Name

 registered? log in!

E-mail (optional)

Website (optional)

  

To ensure security, this site requires unregistered users to enter a verification code:
 
Your code is:  
Enter Code:   

Note: Only registered ShinyDonkey.com users can post images. Only administrators can delete images.

  



"And remember, a shiny new donkey for whoever brings me the head of Colonel Montoya..."
e-mail webmaster