Completed
Last Updated: 25 Oct 2023 06:08 by ADMIN
Release LIB 2023.3.1106 (6 Nov 2023)
Martin Ivanov
Created on: 02 Aug 2023 13:24
Category: DatePicker
Type: Bug Report
2
DatePicker: IndexOutOfRangeException is thrown when AllowParsingWithoutSeparator is set to True and invalid DateTime string is entered

IndexOutOfRangeException is thrown when AllowParsingWithoutSeparator is set to true and an invalid date is entered. 

Examples of invalid date strings that cause the exception:

  • 10120000
  • 12 12 12
  • 1
  • a4/1/2014

There is no proper workaround, but the error is silently printed in the Output pane of Visual Studio and it doesn't break the application or the RadDatePicker control, so it can be ignored.

The exception stacktrace is the following:

System.ArgumentOutOfRangeException: Year must be between 1 and 9999. (Parameter 'year')
   at System.DateTime.DaysInMonth(Int32 year, Int32 month)
   at Telerik.Windows.Controls.MilitaryDateParser.CheckAndSetValidDate(Int32 year, Int32 month, Int32 date, DateTime& fullDate, DateTime current)
   at Telerik.Windows.Controls.MilitaryDateParser.TryParseSingleDigitDatePart(DateTime& result, DateTime current, String datePart, DayMonthYearIndecesInfo dateIndeces, CultureInfo culture)
   at Telerik.Windows.Controls.MilitaryDateParser.TryParse(String value, DateTime& result, DateTime current, CultureInfo culture)
   at Telerik.Windows.Controls.RadDateTimePicker.ParseDateTime(String text, IDateTimeParser parser, Nullable`1& dateTime)
   at Telerik.Windows.Controls.RadDateTimePicker.OnDateTimeTextChanged()
   at Telerik.Windows.Controls.RadDateTimePicker.OnDateTimeTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
   at Telerik.Windows.Controls.RadDateTimePicker.set_DateTimeText(String value)
   at Telerik.Windows.Controls.RadDateTimePicker.UpdateValueFromCurrentText()
   at Telerik.Windows.Controls.RadDateTimePicker.ProcessKey(KeyEventArgs e)
   at Telerik.Windows.Controls.RadDateTimePicker.OnKeyDown(KeyEventArgs e)

1 comment
Margret
Posted on: 07 Aug 2023 08:57
For me the error is not silently printed, but completely crashes the application.