简体   繁体   English

Xamarin.IOS表单LabelRenderer.UpdateText引发NullReferenceException

[英]Xamarin.IOS Forms LabelRenderer.UpdateText throws NullReferenceException

I am using Xamarin.Forms v2.4.0.38779 and I am facing Null Pointer exception which crashes the application. 我正在使用Xamarin.Forms v2.4.0.38779,并且遇到了Null Pointer异常,该异常使应用程序崩溃。 I had same issue with 2.4.0.18342 我在2.4.0.18342中遇到了同样的问题

System.NullReferenceException: Object reference not set to an instance of an object

I guess, Issue occcured while I have ListView with few rows and I am adding new rows, deleting existing rows and also updating values of row based on values, I get from background thread. 我猜想,当ListView的行数很少,并且我要添加新行,删除现有行并根据值更新行值时发生问题,我是从后台线程获取的。

As data comes too frequently, around 100 updates in matter of seconds, It crashes. 由于数据输入过于频繁,因此在几秒钟内约有100次更新,因此它崩溃了。

FYI, I have ObservationCollection binded to ItemSource of ListView. 仅供参考,我已将ObservationCollection绑定到ListView的ItemSource。 So I dont manage addition, removal and update myself. 因此,我不管理自己的添加,删除和更新。

Here is stackttrace: 这是stackttrace:

LabelRenderer.UpdateText ()
LabelRenderer.OnElementPropertyChanged (System.Object sender,System.ComponentModel.PropertyChangedEventArgs e)
(wrapper delegate-invoke) :invoke_void_object_PropertyChangedEventArgs object,System.ComponentModel.PropertyChangedEventArgs)
BindableObject.OnPropertyChanged (System.String propertyName)
Element.OnPropertyChanged (System.String propertyName)
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)
BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, 
Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes)
BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget)
BindingExpression.Apply (System.Boolean fromTarget)
BindingExpression+BindingExpressionPart.<PropertyChanged>b__47_0 ()
NSAsyncActionDispatcher.Apply ()
(wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain(int,string[],intptr,intptr)
UIApplication.Main (System.String[] args, System.String principalClassName,System.String delegateClassName)
Application.Main (System.String[] args)

Does anyone has idea on how to resolve this? 有谁知道如何解决这个问题?

FYI, This is not about how to resolve NullPointerException, as Xamarin.Forms code is not own by me. 仅供参考,这与如何解决NullPointerException有关,因为Xamarin.Forms代码不是我所有的。 I am using that as third party module. 我将其用作第三方模块。

Changing the CachingStrategy on the listview also seems to be a workaround. 更改列表视图上的CachingStrategy似乎也是一种解决方法。 Based on https://bugzilla.xamarin.com/show_bug.cgi?id=59813 . 基于https://bugzilla.xamarin.com/show_bug.cgi?id=59813

For me it was fixed changing CachingStrategy to RecycleElement, but from the link above it has also been reported that changing to RetainElement can be a fix. 对我来说,已修复了将CachingStrategy更改为RecycleElement的问题,但是据报告,从上面的链接可以更改为RetainElement可以解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM