Using ListView in Xamarin.Forms -- Problem with WinPhone in Exercise 4

PortiaBassPortiaBass USMember, University

In Exercise 4 BEFORE the section "Turn on a quick index" is added, the project runs on Android and iOS but NOT on Windows Phone -- see error trace below. After ObservableGrouping.cs (and associated code) is added to the project, the WinPhone project does run. What is going on?

System.Reflection.TargetInvocationException was unhandled by user code
HResult=-2146232828
Message=Exception has been thrown by the target of an invocation.
Source=mscorlib
StackTrace:
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at Xamarin.Forms.Xaml.BaseValueNode.SetPropertyValue(Object xamlelement, XmlName propertyName, Object value, BindableObject rootElement)
at Xamarin.Forms.Xaml.ElementNode.ApplyTo(Object source, XmlName propertyName, Boolean dontUseLazy)
at Xamarin.Forms.Xaml.INodeExtension.ApplyProperties(IElementNode node, Object source, Boolean dontUseLazy)
at Xamarin.Forms.Xaml.RootNode.ApplyProperties(Boolean dontUseLazy)
at Xamarin.Forms.Xaml.XamlLoader.Load(VisualElement view, String xaml)
at Xamarin.Forms.Xaml.XamlLoader.Load(VisualElement view, Type callingType)
at Xamarin.Forms.Xaml.Extensions.LoadFromXaml[TView](TView view, Type callingType)
at MyContacts.AllContacts.InitializeComponent()
at MyContacts.AllContacts..ctor()
at MyContacts.App.GetMainPage()
at MyContacts.WinPhone.MainPage..ctor()
InnerException: System.MethodAccessException
HResult=-2146233072
Message=Attempt by method 'Xamarin.Forms.BindingExpression.ApplyCore(System.Object, Xamarin.Forms.BindableObject, Xamarin.Forms.BindableProperty, Boolean)' to access method 'System.Linq.Lookup2+Grouping<System.__Canon,System.__Canon>.get_Key()' failed. Source=mscorlib 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.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at Xamarin.Forms.BindingExpression.ApplyCore(Object sourceObject, BindableObject target, BindableProperty property, Boolean fromTarget) at Xamarin.Forms.BindingExpression.Apply(Object sourceObject, BindableObject target, BindableProperty property) at Xamarin.Forms.Binding.Apply(Object newContext, BindableObject bindObj, BindableProperty targetProperty) at Xamarin.Forms.BindableObject.ApplyBindings(Object oldContext) at Xamarin.Forms.BindableObject.BindingContextPropertyBindingPropertyChanged(BindableObject bindable, Object oldvalue, Object newvalue) at Xamarin.Forms.BindableObject.SetValueActual(BindableProperty property, Object value, Boolean currentlyApplying, Boolean clearBindings, Boolean raiseOnEqual) at Xamarin.Forms.BindableObject.SetValueCore(BindableProperty property, Object value, Boolean clearBindings, Boolean raiseOnEqual, Boolean checkaccess) at Xamarin.Forms.BindableObject.SetValue(BindableProperty property, Object value, Boolean checkaccess) at Xamarin.Forms.BindableObject.SetValue(BindableProperty property, Object value) at Xamarin.Forms.BindableObject.set_BindingContext(Object value) at Xamarin.Forms.TemplatedItemsList2.InsertGrouped(Object item, Int32 index)
at Xamarin.Forms.TemplatedItemsList2.GroupedReset() at Xamarin.Forms.TemplatedItemsList2.OnCollectionChangedGrouped(NotifyCollectionChangedEventArgs e)
at Xamarin.Forms.TemplatedItemsList2.OnProxyCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e, Boolean fixWindows) at Xamarin.Forms.TemplatedItemsList2.OnProxyCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
at Xamarin.Forms.TemplatedItemsList2.OnItemsSourceChanged(Boolean fromGrouping) at Xamarin.Forms.TemplatedItemsList2.BindableOnPropertyChanged(Object sender, PropertyChangedEventArgs e)
at Xamarin.Forms.BindableObject.OnPropertyChanged(String propertyName)
at Xamarin.Forms.BindableObject.SetValueActual(BindableProperty property, Object value, Boolean currentlyApplying, Boolean clearBindings, Boolean raiseOnEqual)
at Xamarin.Forms.BindableObject.SetValueCore(BindableProperty property, Object value, Boolean clearBindings, Boolean raiseOnEqual, Boolean checkaccess)
at Xamarin.Forms.BindingExpression.ApplyCore(Object sourceObject, BindableObject target, BindableProperty property, Boolean fromTarget)
at Xamarin.Forms.BindingExpression.Apply(Object sourceObject, BindableObject target, BindableProperty property)
at Xamarin.Forms.Binding.Apply(Object newContext, BindableObject bindObj, BindableProperty targetProperty)
at Xamarin.Forms.BindableObject.ApplyBindings(Object oldContext)
at Xamarin.Forms.BindableObject.SetInheritedBindingContext(BindableObject bindable, Object value)
at Xamarin.Forms.Element.set_Parent(Element value)
at Xamarin.Forms.Element.OnChildAdded(Element child)
at Xamarin.Forms.Page.OnInternalAdded(VisualElement view)
at Xamarin.Forms.Page.InternalChildrenOnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
at System.Collections.ObjectModel.ObservableCollection1.OnCollectionChanged(NotifyCollectionChangedEventArgs e) at System.Collections.ObjectModel.ObservableCollection1.InsertItem(Int32 index, T item)
at System.Collections.ObjectModel.Collection`1.Add(T item)
at Xamarin.Forms.ContentPage.set_Content(View value)
InnerException:

Posts

  • VeniLillkallVeniLillkall FIUniversity ✭✭

    I just ran into the same MethodAccessException yesterday with Xamarin.Forms 1.5.0.6447 and Windows Phone 8.
    How to make this work? Other platforms work just fine.

Sign In or Register to comment.