c# - XAMARIN:System.ArgumentException 'jobject' 不能是 IntPtr.Zero

标签 c# android mvvm xamarin xamarin.android

在 XAMARIN 中,使用 MVVM 方法有时当用户遍历返回 ListView 时我们会收到错误,

System.ArgumentException: 'jobject' must not be IntPtr.Zero.
Parameter name: jobject
  at at Android.Runtime.JNIEnv.CallNonvirtualIntMethod (intptr,intptr,intptr) <IL 0x0001f, 0x000d8>
  at at Android.Views.View.get_Visibility () <IL 0x00075, 0x002a3>
  at at Xamarin.Forms.Platform.Android.VisualElementTracker.UpdateIsVisible () <IL 0x00021, 0x00127>
  at at Xamarin.Forms.Platform.Android.VisualElementTracker.HandlePropertyChanged (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x002b3, 0x010d3>
  at at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs) <IL 0x00044, 0x0009f>
  at at Xamarin.Forms.BindableObject.OnPropertyChanged (string) <IL 0x00012, 0x000c7>
  at at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty,object,bool,bool,bool) <IL 0x000a3, 0x004f3>
  at at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty,object,bool,bool,bool) <IL 0x00213, 0x00aeb>
  at at Xamarin.Forms.BindingExpression.ApplyCore (object,Xamarin.Forms.BindableObject,Xamarin.Forms.BindableProperty,bool) <IL 0x00206, 0x01287>
  at at Xamarin.Forms.BindingExpression.Apply (bool) <IL 0x00041, 0x0018b>
  at at Xamarin.Forms.BindingExpression/BindingExpressionPart.<PropertyChanged>b__12 () <IL 0x00007, 0x00053>
  at at Java.Lang.Thread/RunnableImplementor.Run () <IL 0x00011, 0x00097>
  at at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) <IL 0x0000a, 0x000a3>
  at at (wrapper dynamic-method) object.77d235ff-7394-41cf-b895-17e2737816c1 (intptr,intptr) <IL 0x00011, 0x0003b>

最佳答案

原因是 View 模型列表项属性中很少有空值,一旦我们确保填充了所有 View 模型属性,这个错误就解决了。

关于c# - XAMARIN:System.ArgumentException 'jobject' 不能是 IntPtr.Zero,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26658643/

相关文章:

wpf - Combobox.SelectedItem 绑定(bind)到嵌套属性

java - 如何在 Android MVVM 虚拟机中模拟父子关系?

C# 比较 native 类型和可空类型(Int32 和 Int32?)

c# - C# 中的方法计数不计数

c# - 将 MSDN 示例从 C# 转换为 C++/CLI

c# - 什么时候应该使用导航属性来查询数据库?

Android FLAG_ACTIVITY_CLEAR_TOP 无法正常工作?

java - 在屏幕上展开 DataGrid 将使其所有项目可见

wpf - 在 MVVM 中绑定(bind) DocumentViewer

java - 单击时更改按钮颜色 Android Studio