I have an MvxListView with a few items. Each item consists of 2 components, one is visible and the other is not (Gone). The gone component visibility property is bound to a boolean property on the view model,with a boolean visibility value converter.
On list item click, i change the boolean property to true, which makes the gone component to become visible, achieving a sort of expander effect for that particular item.
This works perfectly, 99% of the time.
Once in a while, for some reason i get null reference exception with the following stack trace:
691.32 Problem seen during binding execution for from IsInEditMode to Visibility - problem TargetInvocationException: Exception has been thrown by the target of an invocation.
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
at System.Reflection.MonoProperty.SetValue (System.Object obj, System.Object value, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] index, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
at System.Reflection.PropertyInfo.SetValue (System.Object obj, System.Object value, System.Object[] index) [0x00000] in <filename unknown>:0
at Cirrious.MvvmCross.Binding.Bindings.Target.MvxPropertyInfoTargetBinding.SetValue (System.Object value) [0x00000] in <filename unknown>:0
at Cirrious.MvvmCross.Binding.Bindings.MvxFullBinding.UpdateTargetFromSource (Boolean isAvailable, System.Object value) [0x00000] in <filename unknown>:0
InnerException was NullReferenceException: Object reference not set to an instance of an object
I'm not sure if this is MvvmCross issue, or android view issue, but it might be important to note that the gone component has a button. So while all the items in the list are collapsed, there are no buttons, when i expand 1 item, there is a button and the whole list item becomes unclickable, but the button is clickable (this is an unrelated bug which i plan to fix one day, but currently not important for me).
I'm using MvvmCross v3. I admit i'm not using the most latest build (1 month old), and while its worth a try to see if this happens with new bits, the issue is rare, and hard to reproduce.
I have more detailed stack trace information:
at (wrapper delegate-invoke) <Module>.invoke_void__this___intptr_intptr_intptr_JValue[] (intptr,intptr,intptr,Android.Runtime.JValue[]) <IL 0x00062, 0xffffffff>
at Android.Runtime.JNIEnv.CallVoidMethod (intptr,intptr,Android.Runtime.JValue[]) [0x00000] in /Users/builder/data/lanes/monodroid-lion-bs1/03814ac5/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:364
at Android.Views.View.set_Visibility (Android.Views.ViewStates) [0x0003e] in /Users/builder/data/lanes/monodroid-lion-bs1/03814ac5/source/monodroid/src/Mono.Android/platforms/android-8/src/generated/Android.Views.View.cs:4498
at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___int (object,intptr,intptr,intptr) <IL 0x00054, 0xffffffff>
at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) <IL 0x000c6, 0x00553>
at System.Reflection.MonoProperty.SetValue (object,object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) <IL 0x0006c, 0x00353>
at System.Reflection.PropertyInfo.SetValue (object,object,object[]) <IL 0x00007, 0x000a3>
at Cirrious.MvvmCross.Binding.Bindings.Target.MvxPropertyInfoTargetBinding.SetValue (object) <IL 0x0007b, 0x0033f>
at Cirrious.MvvmCross.Binding.Bindings.MvxFullBinding.UpdateTargetFromSource (bool,object) <IL 0x00054, 0x001f3>
at Cirrious.MvvmCross.Binding.Bindings.MvxFullBinding.<CreateSourceBinding>b__0 (object,Cirrious.MvvmCross.Binding.Bindings.Source.MvxSourcePropertyBindingEventArgs) <IL 0x0000d, 0x00083>
at Cirrious.MvvmCross.Binding.Bindings.Source.MvxSourceBinding.FireChanged (Cirrious.MvvmCross.Binding.Bindings.Source.MvxSourcePropertyBindingEventArgs) <IL 0x0000d, 0x000bf>
at Cirrious.MvvmCross.Binding.Bindings.Source.Leaf.MvxLeafPropertyInfoSourceBinding.OnBoundPropertyChanged () <IL 0x00007, 0x00073>
at Cirrious.MvvmCross.Binding.Bindings.Source.MvxPropertyInfoSourceBinding.SourcePropertyChanged (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00014, 0x000ab>
at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___object_object (object,intptr,intptr,intptr) <IL 0x0005a, 0xffffffff>
at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) <IL 0x000c6, 0x00553>
at System.Reflection.MethodBase.Invoke (object,object[]) <IL 0x00006, 0x0008f>
at Cirrious.MvvmCross.Binding.WeakSubscription.MvxWeakEventSubscription`2.OnSourceEvent (object,TEventArgs) <IL 0x0002b, 0x00137>
at (wrapper delegate-invoke) <Module>.invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00027, 0x00073>
at (wrapper delegate-invoke) <Module>.invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00027, 0x00073>
at (wrapper delegate-invoke) <Module>.invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00027, 0x00073>
at (wrapper delegate-invoke) <Module>.invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00027, 0x00073>
at (wrapper delegate-invoke) <Module>.invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00027, 0x00073>
at (wrapper delegate-invoke) <Module>.invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00027, 0x00073>
at (wrapper delegate-invoke) <Module>.invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00027, 0x00073>
at (wrapper delegate-invoke) <Module>.invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00027, 0x00073>
at (wrapper delegate-invoke) <Module>.invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00027, 0x00073>
at (wrapper delegate-invoke) <Module>.invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00027, 0x00073>
at (wrapper delegate-invoke) <Module>.invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00027, 0x00073>
at (wrapper delegate-invoke) <Module>.invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00027, 0x00073>
at (wrapper delegate-invoke) <Module>.invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00027, 0x00073>
at (wrapper delegate-invoke) <Module>.invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00027, 0x00073>
at (wrapper delegate-invoke) <Module>.invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00027, 0x00073>
at (wrapper delegate-invoke) <Module>.invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00027, 0x00073>
at (wrapper delegate-invoke) <Module>.invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00027, 0x00073>
at (wrapper delegate-invoke) <Module>.invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00027, 0x00073>
at (wrapper delegate-invoke) <Module>.invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00059, 0xffffffff>
at Cirrious.MvvmCross.ViewModels.MvxNotifyPropertyChanged/<>c__DisplayClass1.<RaisePropertyChanged>b__0 () <IL 0x00021, 0x000f7>
at Cirrious.MvvmCross.Droid.Views.MvxAndroidMainThreadDispatcher/<>c__DisplayClass1.<RequestMainThreadAction>b__0 (object) <IL 0x00006, 0x0005b>
at Android.App.SyncContext.Post (System.Threading.SendOrPostCallback,object) [0x00025] in /Users/builder/data/lanes/monodroid-lion-bs1/03814ac5/source/monodroid/src/Mono.Android/src/Android.App/SyncContext.cs:19
at Cirrious.MvvmCross.Droid.Views.MvxAndroidMainThreadDispatcher.RequestMainThreadAction (System.Action) <IL 0x0001f, 0x00173>
at Cirrious.CrossCore.Core.MvxMainThreadDispatchingObject.InvokeOnMainThread (System.Action) <IL 0x0000f, 0x00097>
at Cirrious.MvvmCross.ViewModels.MvxNotifyPropertyChanged.RaisePropertyChanged (string) <IL 0x0002a, 0x001ff>
at Cirrious.MvvmCross.ViewModels.MvxNotifyPropertyChanged.RaisePropertyChanged<bool> (System.Linq.Expressions.Expression`1<System.Func`1<bool>>) <IL 0x0000a, 0x00087>
at Game.GamePlayerViewModel.set_IsInEditMode (bool) [0x00008] in c:\Users\Roman\Documents\Projects\Games\Game\ViewModels\Players\GamePlayerViewModel.cs:74
at Game.GamePlayersViewModel.HandleSelectPlayer (Game.GamePlayerViewModel) [0x0000f] in c:\Users\Roman\Documents\Projects\Game\Game\ViewModels\Players\GamePlayersViewModel.cs:117
at Cirrious.MvvmCross.ViewModels.MvxCommand`1.Execute (object) <IL 0x00015, 0x000bb>
at Cirrious.MvvmCross.Binding.Droid.Views.MvxListView.ExecuteCommandOnItem (System.Windows.Input.ICommand,int) <IL 0x00021, 0x001b7>
at Cirrious.MvvmCross.Binding.Droid.Views.MvxListView.<SetupItemClickListeners>b__0 (object,Android.Widget.AdapterView/ItemClickEventArgs) <IL 0x0000d, 0x00087>
at Android.Widget.AdapterView/IOnItemClickListenerImplementor.OnItemClick (Android.Widget.AdapterView,Android.Views.View,int,long) [0x0000b] in /Users/builder/data/lanes/monodroid-lion- bs1/03814ac5/source/monodroid/src/Mono.Android/platforms/android-8/src/generated/Android.Widget.AdapterView.cs:233
at Android.Widget.AdapterView/IOnItemClickListenerInvoker.n_OnItemClick_Landroid_widget_AdapterView_Landroid_view_View_IJ (intptr,intptr,intptr,intptr,int,long) [0x00018] in /Users/builder/data/lanes/monodroid-lion- bs1/03814ac5/source/monodroid/src/Mono.Android/platforms/android-8/src/generated/Android.Widget.AdapterView.cs:170
at (wrapper dynamic-method) object.5e36d7c3-b7bd-4ceb-af22-a12ff6cf17a9 (intptr,intptr,intptr,intptr,int,long) <IL 0x00029, 0x0009b>
at (wrapper native-to-managed) object.5e36d7c3-b7bd-4ceb-af22-a12ff6cf17a9 (intptr,intptr,intptr,intptr,int,long) <IL 0x00024, 0xffffffff>
Also, the component whose visibility is bound to the property is LinearLayout.
Any ideas?
Thanks in advance
NullReferenceExceptions can be caused by dalvik aborting the process; more logcat output would be able to refute this possibility. - jonp