views:

2600

answers:

5

Does anyone know what this means . . getting this in C# winforms applications

A: 

It means you provided an invalid date somewhere.

Robert Gamble
Isn't that a little too obvious an answer?
boost
It's an obvious question, I don't know how one could be more helpful if the OP won't provide any details.
Robert Gamble
Agreed. We can't help more without further details like code.
lacop
A: 

Others have struggled with this. I suggest looking at these threads on DotNetNuke and DevShed.

boost
+2  A: 

It means that somewhere in the program is attempting to convert to or from an OLE Automation Date outside the valid range 1-January-4713 BC to 31-December-9999 AD. It might have slipped through because OLE Automation Dates are represented as a double.

Start by looking for any uses of the methods:

DateTime.FromOADate

DateTime.ToOADate

frou
+2  A: 

An OADate is represented as a double value whose value is the number of days from midnight on 30 december 1899 (negative values representing earlier dates).

This exception is thrown when trying to convert a value that is outside the valid range of Ole Automation dates to/from a .NET DateTime value (methods DateTime.FromOADate and DateTime.ToOADate - which are also used implicitly for COM Interop).

I believe to be valid for conversion to an OADate the .NET DateTime value needs to be strictly greater than 01/01/0100.

To convert from OADate to a .NET DateTime value, the double value needs to be strictly greater than -657435 (= 01/01/0100) and strictly less than 2958466.0 (01/01/10000).

Joe
A: 

I've used:

try
{
    if (folderItem.ModifyDate.Year != 1899)
    {
        this.FileModifiedDate = folderItem.ModifyDate.ToShortDateString() + " " +
            folderItem.ModifyDate.ToLongTimeString();

    }
}
catch (ArgumentException) { } //we need this because it throws an exception if it's an invalid date...

to deal with the same problem I'm having. It throws the exception when we check the year in my case. Doing nothing on an invalid date is exactly the behavior I want, so this hack works.

lc