Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1650
NullReferenceException when refreshing DataSource (7.2 RC)
posted

Hi there

During testing, I noticed that I can sometimes provoke a NullReferenceException in the grid. The stacktrace is below. The strange thing is: The last invoked line in my application does not even access the grid, it merely passes a refrence to a static helper method (which is never invoked):

GroupEditor.xaml Line 100: UIHelper.SelectFirstVisibleRecord(groupGrid);

The next method on the trace is an internal method of the grid. The only hint I can give you is that I'm evaluating active records in two events that follow each other nearly immediately, but on a single thread. If the grid spans any background threads during binding, this may be a reason. It's also noteworthy that I have a *really* hard time to reproduce the issue (need to wildly provoke refreshes of the data source for minutes).

Just for the record, here's what non-invoked method contains (nothing too fancy here...)

    public static bool SelectFirstVisibleRecord(XamDataGrid grid)
    {
      ViewableRecordCollection records = grid.ViewableRecords;
      if (records.Count > 0)
      {
        grid.SelectedItems.Records.Clear();

        //might be redundant but resolved issues with 7.2 beta
        grid.ActiveRecord = null;
        grid.ActiveRecord = records[0];
        records[0].IsSelected = true;
        return true;
      }
      else
      {
        return false;
      }
    }

Cheers,

Philipp 

 

An unhandled exception occurred:

System.NullReferenceException: Object reference not set to an instance of an object.

   at Infragistics.Windows.DataPresenter.DataPresenterBase.a(Record A_0, Boolean A_1)

   at Infragistics.Windows.DataPresenter.DataPresenterBase.c(Record A_0, Boolean A_1)

   at Infragistics.Windows.DataPresenter.DataPresenterBase.c(DependencyObject A_0, Object A_1)

   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType)

   at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, OperationType operationType, Boolean isInternal)

   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)

   at Infragistics.Windows.DataPresenter.DataPresenterBase.set_ActiveRecord(Record value)

   at CT.ManagementStudio.UI.DataModel.GroupEditor.BindGroups() in P:\My Data\Evolve\Projects\ABB\CT\src\trunk\Tools\CT Management Studio\Management Studio\UI\DataModel\GroupEditor.xaml.cs:line 100

   at CT.ManagementStudio.UI.DataModel.GroupEditor.OnProjectPropertyChanged(String propertyName) in P:\My Data\Evolve\Projects\ABB\CT\src\trunk\Tools\CT Management Studio\Management Studio\UI\DataModel\GroupEditor.xaml.cs:line 48

   at CT.ManagementStudio.UI.Common.CtmsUserControl.OnProjectPropertyChangedInternal(Object sender, PropertyChangedEventArgs e) in P:\My Data\Evolve\Projects\ABB\CT\src\trunk\Tools\CT Management Studio\Management Studio\UI\Common\CtmsUserControl.cs:line 150

   at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)

   at CT.ManagementStudio.ViewModel.CtmsProject.RaisePropertyChangedEvent(String propertyName) in P:\My Data\Evolve\Projects\ABB\CT\src\trunk\Tools\CT Management Studio\Management Studio\ViewModel\CtmsProject.cs:line 392

   at CT.ManagementStudio.ViewModel.CtmsProject.set_ActiveGroup(SyncGroup value) in P:\My Data\Evolve\Projects\ABB\CT\src\trunk\Tools\CT Management Studio\Management Studio\ViewModel\CtmsProject.cs:line 172

   at CT.ManagementStudio.UI.DataModel.DataEditorUtil.AddGroup(CtmsProject Project, SyncGroup parentGroup) in P:\My Data\Evolve\Projects\ABB\CT\src\trunk\Tools\CT Management Studio\Management Studio\UI\DataModel\DataEditorUtil.cs:line 76

   at CT.ManagementStudio.UI.DataModel.GroupTree.AddItem(Object sender, ExecutedRoutedEventArgs e) in P:\My Data\Evolve\Projects\ABB\CT\src\trunk\Tools\CT Management Studio\Management Studio\UI\DataModel\GroupTree.xaml.cs:line 100

   at System.Windows.Input.CommandBinding.OnExecuted(Object sender, ExecutedRoutedEventArgs e)

   at System.Windows.Input.CommandManager.ExecuteCommandBinding(Object sender, ExecutedRoutedEventArgs e, CommandBinding commandBinding)

   at System.Windows.Input.CommandManager.FindCommandBinding(CommandBindingCollection commandBindings, Object sender, RoutedEventArgs e, ICommand command, Boolean execute)

   at System.Windows.Input.CommandManager.FindCommandBinding(Object sender, RoutedEventArgs e, ICommand command, Boolean execute)

   at System.Windows.Input.CommandManager.OnExecuted(Object sender, ExecutedRoutedEventArgs e)

   at System.Windows.UIElement.OnExecutedThunk(Object sender, ExecutedRoutedEventArgs e)

   at System.Windows.Input.ExecutedRoutedEventArgs.InvokeEventHandler(Delegate genericHandler, Object target)

   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)

   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)

   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)

   at System.Windows.UIElement.RaiseEventImpl(RoutedEventArgs args)

   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)

   at System.Windows.Input.RoutedCommand.ExecuteImpl(Object parameter, IInputElement target, Boolean userInitiated)

   at System.Windows.Input.RoutedCommand.ExecuteCore(Object parameter, IInputElement target, Boolean userInitiated)

   at System.Windows.Input.CommandManager.TransferEvent(IInputElement newSource, ExecutedRoutedEventArgs e)

   at System.Windows.Input.CommandManager.OnExecuted(Object sender, ExecutedRoutedEventArgs e)

   at System.Windows.UIElement.OnExecutedThunk(Object sender, ExecutedRoutedEventArgs e)

   at System.Windows.Input.ExecutedRoutedEventArgs.InvokeEventHandler(Delegate genericHandler, Object target)

   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)

   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)

   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)

   at System.Windows.UIElement.RaiseEventImpl(RoutedEventArgs args)

   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)

   at System.Windows.Input.RoutedCommand.ExecuteImpl(Object parameter, IInputElement target, Boolean userInitiated)

   at System.Windows.Input.RoutedCommand.ExecuteCore(Object parameter, IInputElement target, Boolean userInitiated)

   at MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(ICommandSource commandSource, Boolean userInitiated)

   at System.Windows.Controls.MenuItem.InvokeClickAfterRender(Object arg)

   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)

   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
---------------------------
OK  
---------------------------
 

Parents
  • 8576
    Offline posted
    Hi Philipp -
     
    Strange - the code in your SelectFirstVisibleRecord routine looks good (which shouldn't matter if it is not getting invoked), and it appears we are doing null reference checks in all the appropriate places within the Infragistics.Windows.DataPresenter.DataPresenterBase.a(Record A_0, Boolean A_1) method.
     
    What does the code surrounding line 100 in GroupEditor.xaml look like?
     
    Looks like we'll probably need a repro sample to take this further.
     
    Joe Modica
     
Reply Children