This question is locked. New answers and comments are not allowed.
Hi:
I'm trying to bind a grid to specific columns from a LINQ select.
The following works:
but the following does not work:
I get the following error:
System.MethodAccessException was unhandled by user code
Message=Attempt by method 'System.Linq.EnumerableQuery.Create(System.Type, System.Collections.IEnumerable)' to access method 'System.Linq.EnumerableQuery`1<System.__Canon>..ctor(System.Collections.Generic.IEnumerable`1<System.__Canon>)' failed.
StackTrace:
at System.RuntimeMethodHandle.PerformSecurityCheck(Object obj, RuntimeMethodHandleInternal method, RuntimeType parent, UInt32 invocationFlags)
at System.RuntimeMethodHandle.PerformSecurityCheck(Object obj, IRuntimeMethodInfo method, RuntimeType parent, UInt32 invocationFlags)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, Object[] args)
at System.Linq.EnumerableQuery.Create(Type elementType, IEnumerable sequence)
at System.Linq.Queryable.AsQueryable(IEnumerable source)
at Telerik.Windows.Data.QueryableFactory.CreateQueryable(IEnumerable source)
at Telerik.Windows.Data.QueryableCollectionView..ctor(IEnumerable sourceCollection)
at Telerik.Windows.Data.DataItemCollection.CreateCollectionView(IEnumerable source)
at Telerik.Windows.Data.DataItemCollection.SetItemsSource(IEnumerable source)
at Telerik.Windows.Controls.GridView.GridViewDataControl.<>c__DisplayClass44.<Bind>b__43()
at Telerik.Windows.Controls.CursorManager.PerformTimeConsumingOperation(FrameworkElement frameworkElement, Action action)
at Telerik.Windows.Controls.GridView.GridViewDataControl.Bind(Object newValue)
at Telerik.Windows.Controls.GridView.GridViewDataControl.OnItemsSourceChanged(Object oldValue, Object newValue)
at Telerik.Windows.Controls.DataControl.OnItemsSourcePropertyChanged(DependencyObject origin, DependencyPropertyChangedEventArgs args)
at Telerik.Windows.PropertyMetadata.<>c__DisplayClass1.<Create>b__0(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
at Telerik.Windows.Controls.DataControl.set_ItemsSource(Object value)
at HCDA4.ReportGrid.Data_Columns_Ready(Object sender, EventArgs e)
at System.Windows.Ria.OperationBase.Complete(Object result)
at System.Windows.Ria.LoadOperation.Complete(DomainClientResult result)
at System.Windows.Ria.DomainContext.CompleteLoad(IAsyncResult asyncResult)
at System.Windows.Ria.DomainContext.<>c__DisplayClass17.<Load>b__13(Object )
InnerException:
I'm trying to bind a grid to specific columns from a LINQ select.
The following works:
Report_Grid.ItemsSource = |
from z in kdc.entity_ColumnNamesForViews |
where z.ColumnNo <= 10 |
select z; |
Report_Grid.ItemsSource = |
from z in kdc.entity_ColumnNamesForViews |
where z.ColumnNo <= 10 |
select new { Number = z.ColumnNo, Name = z.ColumnName }; |
System.MethodAccessException was unhandled by user code
Message=Attempt by method 'System.Linq.EnumerableQuery.Create(System.Type, System.Collections.IEnumerable)' to access method 'System.Linq.EnumerableQuery`1<System.__Canon>..ctor(System.Collections.Generic.IEnumerable`1<System.__Canon>)' failed.
StackTrace:
at System.RuntimeMethodHandle.PerformSecurityCheck(Object obj, RuntimeMethodHandleInternal method, RuntimeType parent, UInt32 invocationFlags)
at System.RuntimeMethodHandle.PerformSecurityCheck(Object obj, IRuntimeMethodInfo method, RuntimeType parent, UInt32 invocationFlags)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, Object[] args)
at System.Linq.EnumerableQuery.Create(Type elementType, IEnumerable sequence)
at System.Linq.Queryable.AsQueryable(IEnumerable source)
at Telerik.Windows.Data.QueryableFactory.CreateQueryable(IEnumerable source)
at Telerik.Windows.Data.QueryableCollectionView..ctor(IEnumerable sourceCollection)
at Telerik.Windows.Data.DataItemCollection.CreateCollectionView(IEnumerable source)
at Telerik.Windows.Data.DataItemCollection.SetItemsSource(IEnumerable source)
at Telerik.Windows.Controls.GridView.GridViewDataControl.<>c__DisplayClass44.<Bind>b__43()
at Telerik.Windows.Controls.CursorManager.PerformTimeConsumingOperation(FrameworkElement frameworkElement, Action action)
at Telerik.Windows.Controls.GridView.GridViewDataControl.Bind(Object newValue)
at Telerik.Windows.Controls.GridView.GridViewDataControl.OnItemsSourceChanged(Object oldValue, Object newValue)
at Telerik.Windows.Controls.DataControl.OnItemsSourcePropertyChanged(DependencyObject origin, DependencyPropertyChangedEventArgs args)
at Telerik.Windows.PropertyMetadata.<>c__DisplayClass1.<Create>b__0(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
at Telerik.Windows.Controls.DataControl.set_ItemsSource(Object value)
at HCDA4.ReportGrid.Data_Columns_Ready(Object sender, EventArgs e)
at System.Windows.Ria.OperationBase.Complete(Object result)
at System.Windows.Ria.LoadOperation.Complete(DomainClientResult result)
at System.Windows.Ria.DomainContext.CompleteLoad(IAsyncResult asyncResult)
at System.Windows.Ria.DomainContext.<>c__DisplayClass17.<Load>b__13(Object )
InnerException: