This is a migrated thread and some comments may be shown as answers.

Exception during Telerik.Windows.Controls.RadDateTimePicker.OnDateTimeTextChanged - No application stack trace

3 Answers 73 Views
DateTimePicker
This is a migrated thread and some comments may be shown as answers.
Dmitri
Top achievements
Rank 1
Dmitri asked on 05 May 2015, 08:20 AM
I work on a WPF application and face with the following issue: When someone who uses our application encounters an exception, we log it to our DB, including the stack trace of the exception. I've encountered an exception with the following stack trace:

System.ArgumentOutOfRangeException: index and length must refer to a location within the string.
Parameter Name: length
at- System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
at- Telerik.Windows.Controls.MilitaryDateParser.TryParseSingleDigitDatePart(DateTime& result, DateTime current, String datePart, DayMonthYearIndecesInfo dateIndeces)
at- Telerik.Windows.Controls.MilitaryDateParser.TryParse(String value, DateTime& result, DateTime current)
at- Telerik.Windows.Controls.CompositeDateTimeParser.TryParse(String value, DateTime& result, DateTime current)
at- Telerik.Windows.Controls.RadDateTimePicker.ParseDateTime(String text, IDateTimeParser parser, Nullable`1& dateTime)
at- Telerik.Windows.Controls.RadDateTimePicker.OnDateTimeTextChanged()
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- System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at- System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at- System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at- System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args) at- System.Windows.Input.InputManager.ProcessStagingArea()
at- System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at- System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawKeyboardActions actions, Int32 scanCode, Boolean isExtendedKey, Boolean isSystemKey, Int32 virtualKey)
at- System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(MSG& msg, Boolean& handled)
at- System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(MSG& msg, ModifierKeys modifiers)
at- System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param)
at- System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at- MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

The stack trace does not include anything that apply to a line from my application. I understand that something goes wrong with the input given to RadDateTimePicker and it's parsing during OnDateTimeTextChanged().

I want to find out what is the input that fails and also log it, so that next time something goes wrong, I will know the cause.How can I catch the exception, log the input and of course rethrow it?

Basically, in my code, I wrap the RadDateTimePicker with my own control, and bind to its DateTimeTextProperty:

BindingOperations.SetBinding(_radDateTimePicker, RadDateTimePicker.DateTimeTextProperty,
new Binding("DateTimeText")
{
Source = this,
Mode = BindingMode.TwoWay,
UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
});

I can listen to _radDateTimePicker events, for example: _radDateTimePicker.ParseDateTimeValue += OnRadDateTimePickerParseDateTimeValue;
Any suggestions, Please?

I just want to know the input the causes the error, and do something like that in the correct location in code:Try
{
}
Catch (ArgumentOutOfRangeException ex)
{
Throw new ArgumentException(String.Format("The input was {0}", input), ex)
}

Maybe I should put this code within some event of _radDateTimePicker that I listen to.Thanks!

3 Answers, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 08 May 2015, 05:49 AM
Hello Dima,

We were aware of such issue with the Q1 2014 version of Telerik controls. It was caused by the AllowParsingWithoutSeparator property. When it is set to True and a date that contains letters is entered the observed exception was thrown. However, since version Q2 2014 the issue has been fixed. Could you please confirm if this is the case and test if the exception is thrown with the latest official released version of Telerik controls? If so, we will need a sample project that reproduces the observed exception - thus we could be able to continue our investigation.

We're looking forward to hearing from you.

Regards,
Nasko
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Dmitri
Top achievements
Rank 1
answered on 14 May 2015, 01:34 PM
Thank you for the info.
Can you please give me an example of input that might cause the problem? (as I've mentioned, I'm not sure how to reproduce the issue).

This way, I could add some code in my control (that wraps RadDateTimePicker), lets say PreviewKeyDown, and prevent the user from entering that input. Thank you!
0
Nasko
Telerik team
answered on 15 May 2015, 10:39 AM
Hello Dima,

You could reproduce the exception if you enter the date like "07 July 2011" followed by pressing the "Enter" key. Please, notice the AllowParsingWithoutSeparator property should be set to "True" and a date containing letters should be entered - the issue is fixed with the latest official released version.

Hopes this helps.

Regards,
Nasko
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
DateTimePicker
Asked by
Dmitri
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Dmitri
Top achievements
Rank 1
Share this question
or