Exception with DataTable

5 posts, 0 answers
  1. CarlosLima
    CarlosLima avatar
    47 posts
    Member since:
    May 2010

    Posted 13 Dec 2010 Link to this post

    Hi.
    I've tried to use the example from http://blogs.telerik.com/blogs/posts/10-01-22/how_to_serialize_your_datatable_to_silverlight_using_wcf_service.aspx and had to make a small change:

    Instead of IEnumerable<Dictionary<string, object>>

    use

    Dictionary<string, object>[]

    otherwise the service would not return the data to silverlight (probable serialization issue).

    Now on silverlight, when I set the grid's ItemsSource, I get this exception:

    {System.NullReferenceException: Object reference not set to an instance of an object.
       em Telerik.Windows.Data.TypeExtensions.DefaultValue(Type type)
       em Telerik.Windows.Data.Expressions.ExpressionFactory.DefaltValueExpression(Type type)
       em Telerik.Windows.Data.Expressions.ExpressionFactory.MakeMemberAccess(Expression instance, String memberName, Type memberType)
       em Telerik.Windows.Data.Expressions.ExpressionFactory.MakeMemberAccess(Expression instance, String memberName, Type memberType, Boolean liftMemberAccessToNull)
       em Telerik.Windows.Data.Expressions.PropertyAccessExpressionBuilder.CreateMemberAccessExpressionOverride()
       em Telerik.Windows.Data.Expressions.MemberAccessExpressionBuilderBase.CreateMemberAccessExpression()
       em Telerik.Windows.Data.Expressions.EnumerableSelectorAggregateFunctionExpressionBuilder.CreateMemberSelectorExpression()
       em Telerik.Windows.Data.Expressions.EnumerableSelectorAggregateFunctionExpressionBuilder.CreateAggregateExpression()
       em Telerik.Windows.Data.EnumerableSelectorAggregateFunction.CreateAggregateExpression(Expression enumerableExpression)
       em Telerik.Windows.Data.Expressions.GroupDescriptorExpressionBuilder.<ProjectionPropertyValueExpressions>b__3(AggregateFunction f)
       em System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
       em System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
       em System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
       em Telerik.Windows.Data.Expressions.GroupDescriptorExpressionBuilder.CreateProjectionInitExpression()
       em Telerik.Windows.Data.Expressions.GroupDescriptorExpressionBuilder.CreateAggregateFunctionsProjectionMemberBinding()
       em Telerik.Windows.Data.Expressions.GroupDescriptorExpressionBuilder.<CreateMemberBindings>d__0.MoveNext()
       em System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
       em System.Dynamic.Utils.CollectionExtensions.ToReadOnly[T](IEnumerable`1 enumerable)
       em System.Linq.Expressions.Expression.MemberInit(NewExpression newExpression, IEnumerable`1 bindings)
       em Telerik.Windows.Data.Expressions.GroupDescriptorExpressionBuilder.CreateSelectBodyExpression()
       em Telerik.Windows.Data.Expressions.GroupDescriptorExpressionBuilder.CreateResultSelectorExpression()
       em Telerik.Windows.Data.Expressions.GroupDescriptorExpressionBuilder.get_ResultSelectorExpression()
       em Telerik.Windows.Data.Expressions.GroupDescriptorExpressionBuilderBase.CreateQuery()
       em Telerik.Windows.Data.Expressions.GroupDescriptorCollectionExpressionBuilder.CreateQuery()
       em Telerik.Windows.Data.QueryableExtensions.GroupBy(IQueryable source, IEnumerable`1 groupDescriptors)
       em Telerik.Windows.Data.QueryableExtensions.Aggregate(IQueryable source, IEnumerable`1 aggregateFunctions)
       em Telerik.Windows.Controls.GridView.GridViewDataControl.CreateAggregateResults()
       em Telerik.Windows.Controls.GridView.GridViewDataControl.CalculateAggregates()
       em Telerik.Windows.Controls.GridView.GridViewDataControl.<>c__DisplayClass18.<Bind>b__17()
       em Telerik.Windows.Controls.CursorManager.PerformTimeConsumingOperation(FrameworkElement frameworkElement, Action action)
       em Telerik.Windows.Controls.GridView.GridViewDataControl.Bind(Object newValue)
       em Telerik.Windows.Controls.GridView.GridViewDataControl.OnItemsSourceChanged(Object oldValue, Object newValue)
       em Telerik.Windows.Controls.DataControl.OnItemsSourcePropertyChanged(DependencyObject origin, DependencyPropertyChangedEventArgs args)
       em Telerik.Windows.PropertyMetadata.<>c__DisplayClass1.<Create>b__0(DependencyObject d, DependencyPropertyChangedEventArgs e)
       em System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
       em System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
       em System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
       em System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
       em Telerik.Windows.Controls.DataControl.set_ItemsSource(Object value)
       em TSB_Test.Content.DealsMonitoring.DealsMonitoring.client_GetMonitoringDealsUsingPaginationTEMPCompleted(Object sender, GetMonitoringDealsUsingPaginationTEMPCompletedEventArgs e)
       em TSB_Test.Comercial.ComercialServiceClient.OnGetMonitoringDealsUsingPaginationTEMPCompleted(Object state)}


    Any idea why?

    Thanks.

  2. Marco
    Marco avatar
    21 posts
    Member since:
    Aug 2010

    Posted 13 Dec 2010 Link to this post

    Same problem here.

    Is there another solution to send a datatable from a WCF service to silverlight?

    Thanks.
  3. DevCraft banner
  4. Marco
    Marco avatar
    21 posts
    Member since:
    Aug 2010

    Posted 13 Dec 2010 Link to this post

    Forgot to explain that my service doens't return the ienumerable like the example but another class that we've created:

     public class PaginationClauses
        {
            public PaginationClauses()
            {
            }

            public int totalClausesNumber { get; set; }

            public Dictionary<string, object>[] Data { get; set; }
        }

  5. Marco
    Marco avatar
    21 posts
    Member since:
    Aug 2010

    Posted 13 Dec 2010 Link to this post

    Apparently the problem has nothing to do with the data being received from the service.
    I have a grid set on the xaml without any properties besides the name.
    Once the page loads, I have a static class that adds columns to that grid (the grid is passed as an input parameter) and sets each column's properties.
    Finally when the user clicks a button the grid is populated with with the information received as I previously wrote.
    If I create a new radrgridview on that moment and do the same with the itemssource it doesn't return any exception. But somehow it seams that my grid is loosing some property values along the way and that exception occours.

  6. Marco
    Marco avatar
    21 posts
    Member since:
    Aug 2010

    Posted 13 Dec 2010 Link to this post

    Solved it. Thanks.
    Had to do with the way we were programming the aggregate functions.

    Thanks.
Back to Top
DevCraft banner