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

NullReferenceException!!!

1 Answer 116 Views
DomainDataSource
This is a migrated thread and some comments may be shown as answers.
Yonghan
Top achievements
Rank 1
Yonghan asked on 26 Jul 2011, 03:54 AM
Hi,
Thanks for new release, especially supporting IME. the richText cotrol is working good in KOREAN IME.

I've just upgrade new release 2011_2_0712.
But I got a serious problems.
I'm using ria domain data source and late binding a GroupDescriptors.
I don't understand. the exception stack is about telerik stuff, but the xaml and code are not telerik.
Urgently I rollback the update.
these errors are all gone when go back to previous version 2011_1_0419.

see belows
<riaControls:DomainDataSource AutoLoad="False" d:DesignData="{d:DesignInstance my1:Ingredient, CreateList=true}" Height="0"
                              LoadedData="DomainDataSource_LoadedData"
                              LoadingData="DomainDataSource_LoadingdData"
                              x:Name="ingredientDomainDataSource"
                              QueryName="GetIngredientsByQuery" Width="0">
    <riaControls:DomainDataSource.DomainContext>
        <my:RmsDomainContext />
    </riaControls:DomainDataSource.DomainContext>
    <riaControls:DomainDataSource.QueryParameters>
        <riaControls:Parameter ParameterName="process" Value="" />
    </riaControls:DomainDataSource.QueryParameters>
</riaControls:DomainDataSource>

<t:RadGridView x:Name="dataGrid" Grid.Row="1" Style="{StaticResource RMS_RadGridViewStyle}"
                      IsBusy="{Binding ElementName=ingredientDomainDataSource, Path=IsBusy}"
                      AutoExpandGroups="False"
                      RowDetailsVisibilityMode="VisibleWhenSelected"
                      ItemsSource="{Binding ElementName=ingredientDomainDataSource, Path=Data}" >
           <t:RadGridView.Columns>
               <t:GridViewColumn>
                   <t:GridViewColumn.CellTemplate>
                       <DataTemplate>
                           <t:RadButton Style="{StaticResource RMS_DeleteButtonStyle}" CommandParameter="{Binding}"/>
                       </DataTemplate>
                   </t:GridViewColumn.CellTemplate>
               </t:GridViewColumn>
               <t:GridViewDataColumn DataMemberBinding="{Binding Path=Process, Mode=TwoWay}" Header="Process"/>
               <t:GridViewDataColumn CellTemplateSelector="{StaticResource selector}" Header="Category" DataMemberBinding="{Binding Path=Category}"/>
               <t:GridViewDataColumn DataMemberBinding="{Binding Path=Sequence, Mode=TwoWay}" Header="NO" Width="SizeToHeader" />
               <t:GridViewDataColumn DataMemberBinding="{Binding Path=IngredientName}" Header="Ingredient" />
               <t:GridViewDataColumn Header="Unit" Width="60" DataMemberBinding="{Binding Path=Unit}">
                   <t:GridViewDataColumn.CellTemplate>
                       <DataTemplate>
                           <TextBlock Text="{Binding Unit}" />
                       </DataTemplate>
                   </t:GridViewDataColumn.CellTemplate>
                   <t:GridViewDataColumn.CellEditTemplate>
                       <DataTemplate>
                           <t:RadComboBox ItemsSource="{Binding Units, Source={StaticResource CodebookTable}, Mode=OneWay}"
                                          SelectedValue="{Binding Unit, Mode=TwoWay}"
                                          SelectedValuePath="Code" DisplayMemberPath="Code"/>
                       </DataTemplate>
                   </t:GridViewDataColumn.CellEditTemplate>
               </t:GridViewDataColumn>
               <t:GridViewDataColumn DataMemberBinding="{Binding Path=NumberFormat, Mode=TwoWay}" Header="Number Format" Width="*" />
           </t:RadGridView.Columns>
           <t:RadGridView.RowDetailsTemplate>
               <DataTemplate>
                   <Grid Background="#A0FFFFFF">
                       <local:TagbookControl DataContext="{Binding}" Margin="20" />
                   </Grid>
               </DataTemplate>
           </t:RadGridView.RowDetailsTemplate>
           <t:RadGridView.SortDescriptors>
               <t:SortDescriptor Member="Sequence" />
           </t:RadGridView.SortDescriptors>
       </t:RadGridView>

code behind
void OnLoaded(object sender, RoutedEventArgs e)
{
  ingredientDomainDataSource.QueryParameters[0].Value = _process;
 
  if (WebContext.Current.User.IsInRole("Supervisor"))
  {
    _process = "*";
    ingredientDomainDataSource.GroupDescriptors.Add(new GroupDescriptor("Process"));
    ingredientDomainDataSource.GroupDescriptors.Add(new GroupDescriptor("Category"));
  }
  else if (WebContext.Current.User.IsInRole("CSAN") && WebContext.Current.User.IsInRole("Admin"))
  {
    _process = "CSAN";
    ingredientDomainDataSource.GroupDescriptors.Add(new GroupDescriptor("Category")); // ERROR HERE!!
  }
  else if (WebContext.Current.User.IsInRole("PPOLY") && WebContext.Current.User.IsInRole("Admin"))
  {
    _process = "PPOLY";
    ingredientDomainDataSource.GroupDescriptors.Add(new GroupDescriptor("Category"));
  }
   
  ingredientDomainDataSource.AutoLoad = true;
}

Exception
System.NullReferenceException was unhandled by user code
  Message=Object reference not set to an instance of an object.
  StackTrace:
       at Telerik.Windows.Data.TypeExtensions.DefaultValue(Type type)
       at Telerik.Windows.Data.Expressions.ExpressionFactory.DefaltValueExpression(Type type)
       at Telerik.Windows.Data.Expressions.ExpressionFactory.MakeMemberAccess(Expression instance, String memberName, Type memberType)
       at Telerik.Windows.Data.Expressions.ExpressionFactory.MakeMemberAccess(Expression instance, String memberName, Type memberType, Boolean liftMemberAccessToNull)
       at Telerik.Windows.Data.Expressions.PropertyAccessExpressionBuilder.CreateMemberAccessExpressionOverride()
       at Telerik.Windows.Data.Expressions.MemberAccessExpressionBuilderBase.CreateMemberAccessExpression()
       at Telerik.Windows.Data.GroupDescriptor.CreateGroupKeyExpression(ParameterExpression parameterExpression)
       at Telerik.Windows.Data.GroupDescriptorBase.CreateGroupKeyExpression(Expression itemExpression)
       at Telerik.Windows.Data.IGroupDescriptorExtensions.GetGroupKeyType(IGroupDescriptor groupDescriptor, Type itemType)
       at Telerik.Windows.Data.GroupInfo..ctor(IGroupDescriptor groupDescriptor, Type itemType)
       at Telerik.Windows.Data.QueryableCollectionViewGroupRoot..ctor(IEnumerable`1 originalGroups, IEnumerable`1 groupDescriptors, IEnumerable`1 sortDescriptors, Type itemType)
       at Telerik.Windows.Data.QueryableCollectionView.EnsureRootGroup()
       at Telerik.Windows.Data.QueryableCollectionView.get_Groups()
       at Telerik.Windows.Controls.GridView.GridViewItemContainerGenerator.PrepareGrouping()
       at Telerik.Windows.Controls.GridView.GridViewItemContainerGenerator.ResetGeneratorAndReuseContainers()
       at Telerik.Windows.Controls.GridView.GridViewItemContainerGenerator.ReInitializeContainers()
       at Telerik.Windows.Controls.GridView.GridViewDataControl.ReuseContainersOnReset()
       at Telerik.Windows.Controls.GridView.GridViewDataControl.OnItemsChanged(NotifyCollectionChangedEventArgs e)
       at Telerik.Windows.Controls.GridView.BaseItemsControl.OnItemCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
       at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
       at Telerik.Windows.Data.DataItemCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       at Telerik.Windows.Data.DataItemCollection.OnCollectionViewCollectionChanged(NotifyCollectionChangedEventArgs e)
       at Telerik.Windows.Data.DataItemCollection.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(Object sender, NotifyCollectionChangedEventArgs e)
       at Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args)
       at Telerik.Windows.Data.QueryableCollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
       at Telerik.Windows.Data.QueryableCollectionView.RefreshOverride()
       at Telerik.Windows.Data.QueryableCollectionView.RefreshInternal()
       at Telerik.Windows.Data.QueryableCollectionView.RefreshOrDefer()
       at Telerik.Windows.Data.QueryableCollectionView.InvalidatePagingAndRefresh()
       at Telerik.Windows.Data.QueryableCollectionView.OnGroupDescriptorsCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
       at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
       at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       at Telerik.Windows.Data.RadObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       at Telerik.Windows.Data.ObservableItemCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
       at Telerik.Windows.Data.RadObservableCollection`1.InsertItem(Int32 index, T item)
       at System.Collections.ObjectModel.Collection`1.Insert(Int32 index, T item)
       at System.Collections.ObjectModel.Collection`1.System.Collections.IList.Insert(Int32 index, Object value)
       at Telerik.Windows.Data.CollectionHelper.Insert(IList target, IEnumerable newItems, Int32 startingIndex, IEqualityComparer itemComparer)
       at Telerik.Windows.Data.ObservableCollectionManager.HandleCollectionChanged(IList sender, NotifyCollectionChangedEventArgs args)
       at Telerik.Windows.Data.ObservableCollectionManager.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(Object sender, NotifyCollectionChangedEventArgs args)
       at Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args)
       at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
       at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       at Telerik.Windows.Data.RadObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       at Telerik.Windows.Data.ObservableItemCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
       at Telerik.Windows.Data.RadObservableCollection`1.InsertItem(Int32 index, T item)
       at System.Collections.ObjectModel.Collection`1.Insert(Int32 index, T item)
       at System.Collections.ObjectModel.Collection`1.System.Collections.IList.Insert(Int32 index, Object value)
       at Telerik.Windows.Data.CollectionHelper.Insert(IList target, IEnumerable newItems, Int32 startingIndex, IEqualityComparer itemComparer)
       at Telerik.Windows.Data.ObservableCollectionManager.HandleCollectionChanged(IList sender, NotifyCollectionChangedEventArgs args)
       at Telerik.Windows.Data.ObservableCollectionManager.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(Object sender, NotifyCollectionChangedEventArgs args)
       at Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args)
       at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
       at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       at Telerik.Windows.Data.RadObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       at Telerik.Windows.Data.ObservableItemCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
       at Telerik.Windows.Data.RadObservableCollection`1.InsertItem(Int32 index, T item)
       at System.Collections.ObjectModel.Collection`1.Insert(Int32 index, T item)
       at System.Collections.ObjectModel.Collection`1.System.Collections.IList.Insert(Int32 index, Object value)
       at Telerik.Windows.Data.CollectionHelper.Insert(IList target, IEnumerable newItems, Int32 startingIndex, IEqualityComparer itemComparer)
       at Telerik.Windows.Data.ObservableCollectionManager.HandleCollectionChanged(IList sender, NotifyCollectionChangedEventArgs args)
       at Telerik.Windows.Data.ObservableCollectionManager.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(Object sender, NotifyCollectionChangedEventArgs args)
       at Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args)
       at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
       at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
       at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
       at System.Collections.ObjectModel.Collection`1.Insert(Int32 index, T item)
       at System.Windows.Controls.GroupCollectionManager.HandleGroupDescriptorCollectionChanged(NotifyCollectionChangedEventArgs e)
       at System.Windows.Controls.GroupCollectionManager.HandleCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
       at System.Windows.DependencyObjectCollection`1.TryCollectionChanged(NotifyCollectionChangedEventArgs e)
       at System.Windows.DependencyObjectCollection`1.Add(T item)
       at RMS.Views.ProdOprIngredient.OnLoaded(Object sender, RoutedEventArgs e)
       at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
       at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)
  InnerException:


Also, generated the BusyIndictor by Silverlight Business Application is similar error occurred.
    protected virtual void InitializeRootVisual()
    {
      this.busyIndicator = new BusyIndicator();
      this.busyIndicator.Content = new MainPage();
      this.busyIndicator.HorizontalContentAlignment = HorizontalAlignment.Stretch;
      this.busyIndicator.VerticalContentAlignment = VerticalAlignment.Stretch;
      this.RootVisual = this.busyIndicator;
}
 
 
    private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
    {
      // If the app is running outside of the debugger then report the exception using
      // a ChildWindow control.
      if (!System.Diagnostics.Debugger.IsAttached)
      {
        // NOTE: This will allow the application to continue running after an exception has been thrown
        // but not handled.
        // For production applications this error handling should be replaced with something that will
        // report the error to the website and stop the application.
        e.Handled = true;
        ErrorWindow.CreateNew(e.ExceptionObject);
      }
    }
in Application_UnhandledException, the sender is busyIndicator. and the exception stack is about telerik stuff!!



Regards,
Yonghan Yoon.

1 Answer, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 26 Jul 2011, 08:17 AM
Hi Yonghan,

We have tried to reproduce this exception, but unfortunately we could not.

I am sure that you know this, but WCF RIA Services do not support grouping at all. When you add a group descriptor to DDS, you will simply get the data sorted on the respective property. So you can easily use SortDescriptors instead of GroupDescriptors. They do absolutely the same, since WCF RIA Services do not support server-side grouping. But that is up to you.

Now, this does not mean that you have to get this exception. In order to reproduce this exception, we will need a small dummy sample project that reproduces it. Could you please prepare such a dummy over-simplified version of your original project and send it to use so we can debug it. It has to be runnable. Your project can use a freely available database such as Northwind or AdventureWorks, since we have them. The bottom-line is that we need something that we can actually run and debug in order to locate the source of the problem.

Let us know when you prepare such a project.

By the way, did you know that we offer RadDomainDataSource as a direct replacement of Microsoft's DomainDataSource.

Here is more information copied directly from the Release Notes:

Due to the unplanned for increase in interest in development of Silverlight line of business applications, we are making our latest addition to our Silverlight suite available before our next major release so we can enable our clients to focus on delivering their great applications without worrying about any “plumbing”. Our new Domain Data Source components ensure seamless integration between Telerik data source controls and WCF RIA Services. Now all the powerful data-shaping features of Telerik RadControls can directly translate to your domain service – filtering and sorting operations, for example, are performed directly on the server with minimum development effort. Our Domain Data Services support includes both a component that you can embed in your Silverlight page and a CollectionView Implementation that you can use in your view models for a truly MVVM-enabled scenario. 
To explore the new RadDomainDataSource control in greater depth, please check itsonline examples and take a look at the following blog posts:

Maybe you will find our control useful.

Best wishes,
Ross
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
DomainDataSource
Asked by
Yonghan
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Share this question
or