Hello community,
I set up a Xamarin.Forms Project with Xamarin.Android.
Iam using Google Firestore with the Plugin.CloudFirestore plugin.
On my ProfilePage I have a CollectionView with Items. When I select one Item I want to go to the ItemDetailPage where I can edit the Item.
I'm using MVVM.
The following Exception occurs when I am selecting an Item to go to the ItemDetailPage. On the ItemDetailViewModel I have a simple property. When I'm leaving one assignment the crash does not occur:
private double price; public double Price { get { return price; } set { price = value; Item.Price = price; //when I comment out this line everything works fine OnPropertyChanged("Price"); OnPropertyChanged("Item"); } }
Item is also a Property within the ItemDetailViewModel:
private Item item; public Item Item { get { return item; } set { item = value; Title = item.Title; Description = item.Description; Url = item.Url; Price = item.Price; OnPropertyChanged("Item"); } }
Output:
Resolved pending breakpoint at 'C:\Users\InroCusher\source\repos\Project\Project\Project\ViewModels\ItemDetailViewModel.cs:95,1' to void Project.ViewModels.ItemDetailViewModel.set_Price (double value) [0x00008]. **System.Reflection.TargetInvocationException:** 'Exception has been thrown by the target of an invocation.' Thread finished: <Thread Pool> #7 The thread 0x7 has exited with code 0 (0x0). Thread finished: <Thread Pool> #6 The thread 0x6 has exited with code 0 (0x0). Thread started: <Thread Pool> #10 12-08 19:03:27.183 D/Mono ( 6809): DllImport searching in: '__Internal' ('(null)'). 12-08 19:03:27.183 D/Mono ( 6809): Searching for 'java_interop_jnienv_throw'. 12-08 19:03:27.183 D/Mono ( 6809): Probing 'java_interop_jnienv_throw'. 12-08 19:03:27.183 D/Mono ( 6809): Found as 'java_interop_jnienv_throw'. Thread started: <Thread Pool> #11 Thread started: <Thread Pool> #12 **System.Reflection.TargetInvocationException:** 'Exception has been thrown by the target of an invocation.' 12-08 19:03:30.480 E/mono ( 6809): 12-08 19:03:30.480 E/mono ( 6809): Unhandled Exception: 12-08 19:03:30.480 E/mono ( 6809): System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object. 12-08 19:03:30.480 E/mono ( 6809): at Project.ViewModels.ItemDetailViewModel.set_Price (System.Double value) [0x00008] in C:\Users\InroCusher\source\repos\Project\Project\Project\ViewModels\ItemDetailViewModel.cs:95 12-08 19:03:30.480 E/mono ( 6809): at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&) 12-08 19:03:30.480 E/mono ( 6809): at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:395 12-08 19:03:30.480 E/mono ( 6809): --- End of inner exception stack trace --- 12-08 19:03:30.480 E/mono ( 6809): at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00081] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:409 12-08 19:03:30.480 E/mono ( 6809): at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Reflection/MethodBase.cs:53 12-08 19:03:30.480 E/mono ( 6809): at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x002f7] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:183 12-08 19:03:30.480 E/mono ( 6809): at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) [0x0003e] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:53 12-08 19:03:30.481 E/mono ( 6809): at Xamarin.Forms.Binding.Apply (System.Boolean fromTarget) [0x00020] in D:\a\1\s\Xamarin.Forms.Core\Binding.cs:119 12-08 19:03:30.481 E/mono ( 6809): at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00105] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:457 12-08 19:03:30.481 E/mono ( 6809): at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:397 12-08 19:03:30.481 E/mono ( 6809): at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x00214] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:155 12-08 19:03:30.481 E/mono ( 6809): at Xamarin.Forms.BindingExpression.Apply (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property) [0x0006b] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:72 12-08 19:03:30.481 E/mono ( 6809): at Xamarin.Forms.Binding.Apply (System.Object context, Xamarin.Forms.BindableObject bindObj, Xamarin.Forms.BindableProperty targetProperty, System.Boolean fromBindingContextChanged) [0x0006d] in D:\a\1\s\Xamarin.Forms.Core\Binding.cs:138 12-08 19:03:30.481 E/mono ( 6809): at Xamarin.Forms.BindableObject.ApplyBindings (System.Boolean skipBindingContext, System.Boolean fromBindingContextChanged) [0x00041] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:480 12-08 19:03:30.481 E/mono ( 6809): at Xamarin.Forms.BindableObject.SetInheritedBindingContext (Xamarin.Forms.BindableObject bindable, System.Object value) [0x0005a] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:209 12-08 19:03:30.481 E/mono ( 6809): at Xamarin.Forms.Element.SetChildInheritedBindingContext (Xamarin.Forms.Element child, System.Object context) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:475 12-08 19:03:30.481 E/mono ( 6809): at Xamarin.Forms.Element.set_Parent (Xamarin.Forms.Element value) [0x000d2] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:197 12-08 19:03:30.481 E/mono ( 6809): at Xamarin.Forms.Element.OnChildAdded (Xamarin.Forms.Element child) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:320 12-08 19:03:30.481 E/mono ( 6809): at Xamarin.Forms.VisualElement.OnChildAdded (Xamarin.Forms.Element child) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:774 12-08 19:03:30.481 E/mono ( 6809): at Xamarin.Forms.Layout`1[T].OnChildAdded (Xamarin.Forms.Element child) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:22 12-08 19:03:30.481 E/mono ( 6809): at Xamarin.Forms.Layout.OnInternalAdded (Xamarin.Forms.View view) [0x0001d] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:432 12-08 19:03:30.481 E/mono ( 6809): at Xamarin.Forms.Layout.InternalChildrenOnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00080] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:422 12-08 19:03:30.481 E/mono ( 6809): at (wrapper delegate-invoke) <Module>.invoke_void_object_NotifyCollectionChangedEventArgs(object,System.Collections.Specialized.NotifyCollectionChangedEventArgs) 12-08 19:03:30.481 E/mono ( 6809): at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00018] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:263 12-08 19:03:30.481 E/mono ( 6809): at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object item, System.Int32 index) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:338 12-08 19:03:30.481 E/mono ( 6809): at System.Collections.ObjectModel.ObservableCollection`1[T].InsertItem (System.Int32 index, T item) [0x0001a] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.ObjectModel/src/System/Collections/ObjectModel/ObservableCollection.cs:196 12-08 19:03:30.481 E/mono ( 6809): at System.Collections.ObjectModel.Collection`1[T].Add (T item) [0x00020] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Collections/ObjectModel/Collection.cs:71 12-08 19:03:30.481 E/mono ( 6809): at Xamarin.Forms.ObservableWrapper`2[TTrack,TRestrict].Add (TRestrict item) [0x0004b] in D:\a\1\s\Xamarin.Forms.Core\ObservableWrapper.cs:35 12-08 19:03:30.481 E/mono ( 6809): at Project.Views.ItemDetailPage.InitializeComponent () [0x00012] in C:\Users\InroCusher\source\repos\Project\Project\Project\obj\Debug etstandard2.0\Views\ItemDetailPage.xaml.g.cs:22 12-08 19:03:30.481 E/mono ( 6809): at Project.Views.ItemDetailPage..ctor (Project.Models.Item selectedItem) [0x00008] in C:\Users\InroCusher\source\repos\Project\Project\Project\Views\ItemDetailPage.xaml.cs:25 12-08 19:03:30.481 E/mono ( 6809): at Project.ViewModels.ProfilViewModel.set_SelectedItem (Project.Models.Item value) [0x00021] in C:\Users\InroCusher\source\repos\Project\Project\Project\ViewModels\ProfilViewModel.cs:42 12-08 19:03:30.481 E/mono ( 6809): at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&) 12-08 19:03:30.481 E/mono ( 6809): at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:395 12-08 19:03:30.481 E/mono ( 6809): --- End of inner exception stack trace --- 12-08 19:03:30.481 E/mono ( 6809): at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.100(intptr,intptr,intptr,intptr,int,long) 12-08 19:03:30.481 E/mono ( 6809): at (wrapper native-to-managed) Android.Runtime.DynamicMethodNameCounter.100(intptr,intptr,intptr,intptr,int,long) 12-08 19:03:30.483 E/mono-rt ( 6809): [ERROR] FATAL UNHANDLED EXCEPTION: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object. 12-08 19:03:30.483 E/mono-rt ( 6809): at Project.ViewModels.ItemDetailViewModel.set_Price (System.Double value) [0x00008] in C:\Users\InroCusher\source\repos\Project\Project\Project\ViewModels\ItemDetailViewModel.cs:95 12-08 19:03:30.483 E/mono-rt ( 6809): at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&) 12-08 19:03:30.483 E/mono-rt ( 6809): at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:395 12-08 19:03:30.483 E/mono-rt ( 6809): --- End of inner exception stack trace --- 12-08 19:03:30.483 E/mono-rt ( 6809): at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00081] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:409 12-08 19:03:30.483 E/mono-rt ( 6809): at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Reflection/MethodBase.cs:53 12-08 19:03:30.483 E/mono-rt ( 6809): at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x002f7] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:183 12-08 19:03:30.483 E/mono-rt ( 6809): at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) [0x0003e] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:53 12-08 19:03:30.483 E/mono-rt ( 6809): at Xamarin.Forms.Binding.Apply (System.Boolean fromTarget) [0x00020] in D:\a\1\s\Xamarin.Forms.Core\Binding.cs:119 12-08 19:03:30.483 E/mono-rt ( 6809): at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00105] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:457 12-08 19:03:30.483 E/mono-rt ( 6809): at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:397 12-08 19:03:30.483 E/mono-rt ( 6809): at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x00214] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:155 12-08 19:03:30.483 E/mono-rt ( 6809): at Xamarin.Forms.BindingExpression.Apply (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property) [0x0006b] in D:\a\1\s\Xamarin.Forms.Core\BindingExpression.cs:72 12-08 19:03:30.483 E/mono-rt ( 6809): at Xamarin.Forms.Binding.Apply (System.Object context, Xamarin.Forms.BindableObject bindObj, Xamarin.Forms.BindableProperty targetProperty, System.Boolean fromBindingContextChanged) [0x0006d] in D:\a\1\s\Xamarin.Forms.Core\Binding.cs:138 12-08 19:03:30.483 E/mono-rt ( 6809): at Xamarin.Forms.BindableObject.ApplyBindings (System.Boolean skipBindingContext, System.Boolean fromBindingContextChanged) [0x00041] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:480 12-08 19:03:30.483 E/mono-rt ( 6809): at Xamarin.Forms.BindableObject.SetInheritedBindingContext (Xamarin.Forms.BindableObject bindable, System.Object value) [0x0005a] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:209 12-08 19:03:30.483 E/mono-rt ( 6809): at Xamarin.Forms.Element.SetChildInheritedBindingContext (Xamarin.Forms.Element child, System.Object context) [0x00000] in D:\a\1\s\Xamarin.Forms.C 12-08 19:03:30.483 D/HostConnection( 6809): HostConnection::get() New Host Connection established 0xebb21900, tid 6809 12-08 19:03:30.486 D/HostConnection( 6809): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_2
Can anybody help? If more code is needed I can provide it. Thank you!