Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meaning of exception in C# app: "Not a legal OleAut date"?

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

Not a legal OleAut date

like image 468
leora Avatar asked Nov 22 '08 01:11

leora


People also ask

What is exception explain?

Definition: An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program's instructions. When an error occurs within a method, the method creates an object and hands it off to the runtime system.

What is exception and examples?

An event that occurs during the execution of a program that disrupts the normal flow of instructions is called an exception. Example: public static void Main ()

Is there exceptions in C?

The C programming language does not support exception handling nor error handling. It is an additional feature offered by C. In spite of the absence of this feature, there are certain ways to implement error handling in C. Generally, in case of an error, most of the functions either return a null value or -1.

What is the use of exception?

Exceptions provide the means to separate the details of what to do when something out of the ordinary happens from the main logic of a program. In traditional programming, error detection, reporting, and handling often lead to confusing spaghetti code.


2 Answers

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

like image 127
xyz Avatar answered Oct 12 '22 01:10

xyz


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

like image 39
Joe Avatar answered Oct 12 '22 02:10

Joe