I found the statement as blow(http://referencesource.microsoft.com/#System.Windows.Forms/winforms/Managed/System/WinForms/DateTimePicker.cs,85):
In the source code of "Task Scheduler Managed Wrapper", I find cod as blow in the FullDateTimePicker:
As I know, FullDateTimePicker is wrapper of Date and Time, and "dateTimePickerTime" just to save the time of days. so if change the statement into
Another option, limit the Datetime input in UI, just not allow to input the Datetime older than 9998-12-31 0:00:00.
Hope it be helpful.
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public static readonly DateTime MaxDateTime = new DateTime(9998, 12, 31);
It seem that the max value of the DateTimePicker is 9998-12-31, so the time older than 9998-12-31 0:00:00 will cause this exception(such as 9998-12-31 1:00:00).In the source code of "Task Scheduler Managed Wrapper", I find cod as blow in the FullDateTimePicker:
private void DataToControls()
{
DateTime displayTime = currentValue.Kind == DateTimeKind.Utc ? currentValue.ToLocalTime() : currentValue;
dateTimePickerDate.Value = displayTime.Date;
dateTimePickerTime.Value = displayTime;
if (!string.IsNullOrEmpty(utcPrompt))
utcCheckBox.Checked = currentValue.Kind != DateTimeKind.Unspecified;
}
When the day older than 9998-12-31 0:00:00, "dateTimePickerTime.Value = displayTime;" will throw a exception.As I know, FullDateTimePicker is wrapper of Date and Time, and "dateTimePickerTime" just to save the time of days. so if change the statement into
dateTimePickerTime.Value = DateTime.Now.Date + displayTime.TimeOfDay;
ordateTimePickerTime.Value = dateTimePickerTime.MinDate + displayTime.TimeOfDay;
Maybe the problem will be fixed.Another option, limit the Datetime input in UI, just not allow to input the Datetime older than 9998-12-31 0:00:00.
Hope it be helpful.