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

4 posts, 0 answers
  1. Dima
    Dima avatar
    6 posts
    Member since:
    Oct 2014

    Posted 05 May 2015 Link to this post

    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!
  2. Nasko
    Admin
    Nasko avatar
    588 posts

    Posted 08 May 2015 Link to this post

    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.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Dima
    Dima avatar
    6 posts
    Member since:
    Oct 2014

    Posted 14 May 2015 Link to this post

    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!
  5. Nasko
    Admin
    Nasko avatar
    588 posts

    Posted 15 May 2015 Link to this post

    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
Back to Top