我有一个带有SyncFusion列表视图(SfListView)的Xamarin.Forms应用程序。导致Android频繁死机,错误如下:
Unhandled exception: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Syncfusion.ListView.XForms.Android.ExtendedScrollViewRenderer'.
at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <7cfbebb561c54efc9010b018c0846c7e>:0
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualBooleanMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <7cfbebb561c54efc9010b018c0846c7e>:0
at Android.Views.View.get_IsLayoutRequested () [0x0000a] in <9ef29c909d7e4606a46b131129da3975>:0
at Xamarin.Forms.Platform.Android.ScrollViewRenderer+<OnScrollToRequested>d__58.MoveNext () [0x000ce] in D:\agent\_work\1\s\Xamarin.Forms.Platform.Android\Renderers\ScrollViewRenderer.cs:309
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0
at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in <9ef29c909d7e4606a46b131129da3975>:0
at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <9ef29c909d7e4606a46b131129da3975>:0
at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <9ef29c909d7e4606a46b131129da3975>:0
at (wrapper dynamic-method) System.Object:ab79b1ac-9c45-4d56-89ec-c42ce2376e50 (intptr,intptr)
我已经联系了SyncFusion,他们说这是一个框架问题。
列表视图被呈现到一个自定义选项卡式容器中。
与Xamarin.Forms 2.3到2.5 (最新版本)一起使用,但问题仍然存在。对此有什么建议或想法吗?
发布于 2020-02-24 23:13:48
在this thread上可能有一个解决方案,只需查看评论即可。问题的根源似乎在于清除ObservableCollection列表的方式;您应该尝试将其分配给新列表,而不是使用.Clear()方法:
因此,不是:
ObservableCollectionProperty.Clear();
使用:
ObservableCollectionProperty = new ObservableCollection<TypeGoesHere>();
希望这会有所帮助,因为它似乎解决了我在提供的链接中提到的自定义控件所面临的问题。
https://stackoverflow.com/questions/47369244
复制相似问题