NullReferenceException on closing

3 posts, 0 answers
  1. Matthias Bibo
    Matthias Bibo avatar
    72 posts
    Member since:
    Mar 2010

    Posted 02 Oct 2013 Link to this post

    Hello,

    we get a NullReferenceException, when closing a dialog with a RadAutoCompleteBox.
    On closing the dialog we call our Dispose() method in the viewmodel, which clears all collections (also the one which is bound to the ItemsSource of the RadAutoCompleteBox). This will result in a NullReferenceException.

    Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
    StackTrace:
    bei Telerik.Windows.Controls.RadAutoCompleteBox.OnItemsSourceCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
    bei System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
    bei System.Collections.ObjectModel.ObservableCollection`1.ClearItems()
    bei System.Collections.ObjectModel.Collection`1.Clear()
    bei Bdl.DialogCrm.Silverlight.ViewModels.ImportManagerViewModel.Dispose()
    bei Bdl.DialogCrm.Silverlight.Core.ViewManagement.Bases.ContainerViewModelBase`1.ExecuteCloseViewInstance(ViewInstanceDescription desc)
    bei Bdl.DialogCrm.Silverlight.ViewModels.MainViewModel.ExecuteCloseViewInstance(ViewInstanceDescription desc)
    bei Microsoft.Practices.Prism.Commands.DelegateCommand`1.<>c__DisplayClass6.<.ctor>b__2(Object o)
    bei Microsoft.Practices.Prism.Commands.DelegateCommandBase.Execute(Object parameter)
    bei Microsoft.Practices.Prism.Commands.DelegateCommandBase.System.Windows.Input.ICommand.Execute(Object parameter)
    bei Telerik.Windows.Controls.RadButton.ExecuteCommand()
    bei Telerik.Windows.Controls.RadButton.OnClick()
    bei Bdl.DialogCrm.Silverlight.Core.BDLControls.BDLButton.OnClick()
    bei System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
    bei System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
    bei MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName, UInt32 flags)


    private void OnItemsSourceCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
            {
                string searchText = this.SearchText;
                this.autoCompleteHelper.Populate(searchText);
            }

    I looked a the code and I assume, that the Dispose() method ofthe RadAutoCompleteBox was executed and the AutocompleteHelper is null at this moment and should be checked before accessing.

    private void OnItemsSourceCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
    {
                string searchText = this.SearchText;
                if (this.autoCompleteHelper != null)
                {
                           this.autoCompleteHelper.Populate(searchText);
                }
    }



  2. George
    Admin
    George avatar
    1332 posts

    Posted 04 Oct 2013 Link to this post

    Hello Matthias,

    Thank you for pinpointing us this exception with RadAutoCompleteBox. Can you share with us some code so we can reproduce it on our side? This will definitely help us in resolving the problem.

    Regards,
    George
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. DevCraft banner
  4. Matthias Bibo
    Matthias Bibo avatar
    72 posts
    Member since:
    Mar 2010

    Posted 08 Oct 2013 Link to this post

    Hello,

    I showed the code from the RadAutoCompleteBox in Telerik.windows.Controls.dll where the excpetions occured and posted an correction suggestion, but this was for an older version of the dll.

    With the newest internal build the failure does not occur anymore.!
    I can see in the current version, that this code part has been reworked and uses the FocusManager to check if the Box has the focus.

    private void OnItemsSourceCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
            {
                this.Populate(this.SearchText);
            }
     
    public void Populate(string searchText)
            {
                if (FocusManagerHelper.IsKeyboardFocusWithin(this))
                {
                    this.autoCompleteHelper.Populate(searchText);
                }
            }

    So this issue is resolved.
Back to Top