Last post Dec 06, 2011 07:05 PM by thuff
Dec 06, 2011 04:22 PM|thuff|LINK
I randomly get this error "Not a legal OleAut date". I am reading binary data files and putting the datetime from them into arrays. As you can see in the screenshot it successfully puts the data in the array just a couple lines up but when it trys to convert
it again it pukes... Anyone please help this is getting annoying with its random failing.
In case the image doesn't display the link is http://imageshack.us/photo/my-images/11/errorau.jpg
Dec 06, 2011 04:30 PM|ddelella|LINK
If your going to read the binary files into arrays I would recommend reading the data into a DataTable with predefined types or user type specific collections like List(Of DateTime). The value appears to be a standard DateTime format so you should not need
to use DateTime.FromOADate. This method takes a double as a parameter which you do not have. I would use DateTime.Parse instead.
Dec 06, 2011 04:40 PM|thuff|LINK
The FromOADate is making it a standard date time format. If you look at the PassFile_DataField_Definition[TimeStamp_Field_Number].Value it is 3.127928...... then adds the newly created date time into the array with PassTimesStart.Add(PassStartTime)
Dec 06, 2011 06:46 PM|deepak2007in|LINK
The reason is the double value you are using is lot more than the supported value. Execute the program below and you would easily understand what you were doing wrong.
double minimumDateDouble = -6.57434E+5; //Minimum Date and Time Supported - 01/01/0100 12:00 AM
double maximumDateDouble = 2.958465E+6; //Maximum Date and Time Supported - 12/31/9999 12:00 AM
double yourInvalidDateDouble = 3.1279282221645798E+32; //More than Maximum Date and Time Supported
Please let me know if still any part is not understood to you.
Dec 06, 2011 07:05 PM|thuff|LINK
I solved the problem about 5 minutes ago. This program reads a network path to get the .dat files to process. When there is only 1 file in the folder it runs perfect. Over the course of the day more and more files get added to the folder. When getting ready
to read the binary file the program calculates the number of fields expected in the file (in this case 28) and adds the expected sizes together based on the data types 27 singles and one double per record for a total size of 116 bytes. After each file it processed
the number of data fields 28 would grow by 28 each time. 28, 56, 84, etc. This was unintentional. This caused the pointer in the stream reader to move farther and farther ahead each time until it got a number that was out of the range of the FromOADate. The
solution was a one liner: Number_Of_PassFile_DataFields = 0; placed right before the for loop solved the problem.
Thanks for all your help. Half a day wasted for a single logic error....