Xamarin.forms: System.ObjectDisposedException:无法访问已处置的对象'Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer'

创建于 2020-05-20  ·  73评论  ·  资料来源: xamarin/Xamarin.Forms

_此问题已从开发者社区的票证中移出。


升级到Xamarin Forms 4.6.0726后,开始在Android上频繁出现间歇性崩溃。 经调查,发现这是来自Xamarin的LabelRenderer

05-17 07:27:06.656 E / mono(5133):
05-17 07:27:06.656 E / mono(5133):未处理的异常:
05-17 07:27:06.656 E / mono(5133):System.ObjectDisposedException:无法访问已处置的对象。
05-17 07:27:06.656 E / mono(5133):对象名称:“ Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer”。
05-17 07:27:06.656 E / mono(5133):at(包装动态方法)Android.Runtime.DynamicMethodNameCounter.29(intptr,intptr)
05-17 07:27:06.656 E / mono(5133):at(wrapper native-to-managed)Android.Runtime.DynamicMethodNameCounter.29(intptr,intptr)
05-17 07:27:06.656 E / mono-rt(5133):[错误]致命的异常异常:System.ObjectDisposedException:无法访问已处置的对象。
05-17 07:27:06.656 E / mono-rt(5133):对象名称:'Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer'。
05-17 07:27:06.656 E / mono-rt(5133):at(包装动态方法)Android.Runtime.DynamicMethodNameCounter.29(intptr,intptr)
05-17 07:27:06.656 E / mono-rt(5133):at(wrapper native-to-managed)Android.Runtime.DynamicMethodNameCounter.29(intptr,intptr)
05-17 07:27:06.698 D /(5133):HostConnection :: get()建立新的主机连接0xbd1b1240,tid 5133

不知道它来自哪里。 我将ListView作为主视图,并且想知道ListView的较新版本出了什么问题,导致泄漏和崩溃。

我没有自定义标签渲染器,因此它必须来自Xamarin的平台渲染器
请提出建议。


原始评论

2020年5月17日下午11:54的Visual Studio反馈系统:

我们已将您的反馈意见定向到适当的工程团队进行进一步评估。 该团队将审核反馈并通知您有关后续步骤的信息。


原始解决方案

(无解决方案)

4.4.0 collectionview fastrenderers label listview 5 feedback-ticket high regression in-progress high impact Android unverified bug

最有用的评论

如此长时间以来,在经过如此多的投诉之后,微软如何期望使用该平台来创建具有这种基本缺陷的任何企业应用程序,这是完全荒谬的!

在过去的4个月中,我们一直无法发布应用程序Android版本的更新,而我们从此线程获得的所有信息是,当世界其他地方都可以轻松复制时,它们无法重现!!!

在修复此错误之前,Microsoft应该停止做任何事情。 发行任何较新版本的Xamarin都是毫无意义的!!!

所有73条评论

相关#8262

解决方法-https : //github.com/xamarin/Xamarin.Forms/issues/8262#issuecomment -550022425

为ListView或其单元格构建自定义渲染器是一种减少布局计算对滚动性能影响的方法。
ListView最佳做法-https://docs.microsoft.com/zh-cn/xamarin/xamarin-forms/user-interface/listview/performance

尝试为包含ListView的类实现INotifyPropertyChanged (System.ComponentModel)。
public event PropertyChangedEventHandler PropertyChanged设置处理程序,如下所示:

var args = new PropertyChangedEventArgs(nameOf(typeOf(string)));
PropertyChanged?.Invoke(this, args);

相关#10159

您能否附上一个演示此问题的小项目? 谢谢!

我也遇到了同样的问题,导致我的应用崩溃

堆栈跟踪:

Cannot access a disposed object. Object name: 'Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer'.
Java.Interop.JniPeerMembers.AssertSelf(Java.Interop.IJavaPeerable self) in <26521a5118b44c858c385715922b9d5d>
Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualObjectMethod(System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) in <26521a5118b44c858c385715922b9d5d>
Android.Views.View.get_Context() in <4ccdb3137d974856b786e1aeebbfbab6>
Xamarin.Forms.Platform.Android.Platform.GetNativeSize(Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint) in D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:1341
Xamarin.Forms.Forms+AndroidPlatformServices.GetNativeSize(Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint) in D:\a\1\s\Xamarin.Forms.Platform.Android\Forms.cs:930
Xamarin.Forms.VisualElement.OnSizeRequest(System.Double widthConstraint, System.Double heightConstraint) in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:800
Xamarin.Forms.VisualElement.OnMeasure(System.Double widthConstraint, System.Double heightConstraint) in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:783
Xamarin.Forms.VisualElement.GetSizeRequest(System.Double widthConstraint, System.Double heightConstraint) in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:659
Xamarin.Forms.VisualElement.Measure(System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:717
Xamarin.Forms.StackLayout.CalculateNaiveLayout(Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint) in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:163
Xamarin.Forms.StackLayout.CalculateLayout(Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders) in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:123
Xamarin.Forms.StackLayout.OnSizeRequest(System.Double widthConstraint, System.Double heightConstraint) in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:80
Xamarin.Forms.VisualElement.OnMeasure(System.Double widthConstraint, System.Double heightConstraint) in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:783
Xamarin.Forms.VisualElement.GetSizeRequest(System.Double widthConstraint, System.Double heightConstraint) in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:659
Xamarin.Forms.Layout.GetSizeRequest(System.Double widthConstraint, System.Double heightConstraint) in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:132
Xamarin.Forms.VisualElement.Measure(System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:717
Xamarin.Forms.StackLayout.CalculateNaiveLayout(Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint) in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:198
Xamarin.Forms.StackLayout.CalculateLayout(Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders) in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:123
Xamarin.Forms.StackLayout.LayoutChildren(System.Double x, System.Double y, System.Double width, System.Double height) in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:58
Xamarin.Forms.Layout.UpdateChildrenLayout() in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:266
Xamarin.Forms.Layout.OnSizeAllocated(System.Double width, System.Double height) in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:224
Xamarin.Forms.VisualElement.SizeAllocated(System.Double width, System.Double height) in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:805
Xamarin.Forms.Layout.ResolveLayoutChanges() in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:392
Java.Lang.Thread+RunnableImplementor.Run() in <4ccdb3137d974856b786e1aeebbfbab6>
Java.Lang.IRunnableInvoker.n_Run(System.IntPtr jnienv, System.IntPtr native__this) in <4ccdb3137d974856b786e1aeebbfbab6>
(wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.48(intptr,intptr)

将XF降级到4.4.0.991864版可以解决我们生产应用中的问题。 积分: https :

您能否附上一个演示此问题的小项目? 谢谢!

@samhouts我无法发布源代码,它是一个商业应用程序,它只能处理数据。

您能否附上一个演示此问题的小项目? 谢谢!

@samhouts很抱歉,由于合同原因,我无法发布代码

您好,只需检查何时有可用的修复程序。 升级Xamarin框架后,由于这个问题,我们有一个主要版本即将发布,现在暂停。 在这一点上,我们也不能回到旧框架。

请帮忙。

不复制就很难解决这些问题。 您可以通过启用旧版渲染器来解决它。 如果您能够发布复制项目,我们也许可以完全解决问题。 谢谢!

不复制就很难解决这些问题。 您可以通过启用旧版渲染器来解决它。 如果您能够发布复制项目,我们也许可以完全解决问题。 谢谢!

我了解,我正在尝试复制测试项目。

不复制就很难解决这些问题。 您可以通过启用旧版渲染器来解决此问题。 如果您能够发布复制项目,我们也许可以完全解决问题。 谢谢!

@samhouts ,我尝试按照提供的说明启用旧版渲染器,但是令人惊讶的是错误仍然存​​在!

我尝试清洁解决方案,关闭/打开VS,但错误仍然存​​在。

请提出建议。 在这方面的任何帮助将大有帮助!

你好,

尝试跟进以查看是否有任何更新,或什么时候期望对此进行更新?

我们也遇到了这个问题,确实很难复制,应用随机崩溃,
从Xamarin 4.4升级到4.6.0726后,该问题开始发生。

我需要将其移到资源受阻的位置,直到可以复制为止。

@samhouts这看起来与#10159非常相似,这是一个非常严重的问题。 你能看看吗? 有评论提供repro示例。

我创建了一个示例存储库,您可以在其中查看此异常: https :

我还发布了一个视频,展示了如何重现该错误:
https://www.youtube.com/watch?v=yDhlI4BG8D8&feature=youtu.be

描述

当我向CollectionView内的Label的FontSize属性添加绑定并随设备旋转时(在每次旋转中,我都会更新CollectionView的Labels的FontSize)。

System.ObjectDisposedException:'无法访问已处置的对象。
对象名称:“ Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer”。

重现步骤

使用设备旋转时,将元素添加到CollectionView的Source中。

基本信息

  • 由于没有Apple设备,因此我仅在Android上进行过尝试。
  • Xamarin.Forms 4.7.0.1239
  • Android 10

@samhouts在使用Xamarin.Forms存储库在我的机器上进行了一些测试之后,我跟踪了错误的踪迹,该错误恰好发生在Platform.cs类的这一行中: https :

我将方法包装在try catch中以获取StackTrace,这是结果:
在Java.Interop.JniPeerMembers.AssertSelf(Java.Interop.IJavaPeerable自身)中[0x00029]0:
在Java.Interop.JniPeerMembers + JniInstanceMethods.InvokeNonvirtualObjectMethod(System.String encodingMember,Java.Interop.IJavaPeerable self,Java.Interop.JniArgumentValue *参数)[0x00000]中0:
在/Users/builder/azdo/_work/204/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-29/mcw/Android中的Android.Views.View.get_Context()[0x00000] .Views.View.cs:5598
在C:Users \ SourceReposXamarin.FormsXamarin.Forms.Platform.AndroidPlatform.cs中的Xamarin.Forms.Platform.Android.Platform.GetNativeSize(Xamarin.Forms.VisualElement视图,System.Double widthConstraint,System.Double heightConstraint)[0x0001c] 1343

有人为此解决了吗?

我在项目中遇到了同样的错误。 我有Xamarin.Forms 4.6.0.726版本。
堆栈跟踪:

  at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <dac4c5a4b77f4e61a5e6d9d3050dfb9f>:0 
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <dac4c5a4b77f4e61a5e6d9d3050dfb9f>:0 
  at Android.Views.View.get_Context () [0x00000] in /Users/builder/azdo/_work/204/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-29/mcw/Android.Views.View.cs:5598 
  at Xamarin.Forms.Platform.Android.Platform.GetNativeSize (Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint) [0x00019] in D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:1341 
  at Xamarin.Forms.Forms+AndroidPlatformServices.GetNativeSize (Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\Forms.cs:930 
  at Xamarin.Forms.VisualElement.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00025] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:800 
  at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:783 
  at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:659 
  at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:717 
  at Xamarin.Forms.Grid.CalculateAutoCells (System.Double width, System.Double height) [0x000e5] in D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:133 
  at Xamarin.Forms.Grid.MeasureGrid (System.Double width, System.Double height, System.Boolean requestSize) [0x0000c] in D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:485 
  at Xamarin.Forms.Grid.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x0002a] in D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:60 
  at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:783 
  at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:659 
  at Xamarin.Forms.Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:132 
  at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:717 
  at Xamarin.Forms.TemplatedView.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x0003c] in D:\a\1\s\Xamarin.Forms.Core\TemplatedView.cs:43 
  at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:783 
  at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:659 
  at Xamarin.Forms.Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:132 
  at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:717 
  at Xamarin.Forms.StackLayout.CalculateNaiveLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint) [0x000a8] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:163 
  at Xamarin.Forms.StackLayout.CalculateLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders) [0x00058] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:123 
  at Xamarin.Forms.StackLayout.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00019] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:80 
  at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:783 
  at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:659 
  at Xamarin.Forms.Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:132 
  at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:717 
  at Xamarin.Forms.StackLayout.CalculateNaiveLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint) [0x000a8] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:163 
  at Xamarin.Forms.StackLayout.CalculateLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders) [0x00058] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:123 
  at Xamarin.Forms.StackLayout.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00019] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:80 
  at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:783 
  at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:659 
  at Xamarin.Forms.Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:132 
  at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:717 
  at Xamarin.Forms.StackLayout.CalculateNaiveLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint) [0x000a8] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:163 
  at Xamarin.Forms.StackLayout.CalculateLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders) [0x00058] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:123 
  at Xamarin.Forms.StackLayout.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x0004e] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:58 
  at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00158] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:266 
  at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:224 
  at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:805 
  at Xamarin.Forms.Layout.ResolveLayoutChanges () [0x0005c] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:392 
  at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in /Users/builder/azdo/_work/204/s/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36 
  at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in /Users/builder/azdo/_work/204/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-29/mcw/Java.Lang.IRunnable.cs:81 
  at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.1(intptr,intptr)

应用程序输出窗口显示以下输出:

[mono]未处理的异常:
[mono] System.ObjectDisposedException:无法访问已处置的对象。
[mono]对象名称:“ Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer”。
[mono] at(wrapper dynamic-method)Android.Runtime.DynamicMethodNameCounter.1(intptr,intptr)
[包装]本机(托管到托管)Android.Runtime.DynamicMethodNameCounter.1(intptr,intptr)
[mono-rt] [错误]致命异常:System.ObjectDisposedException:无法访问已处置的对象。
[mono-rt]对象名称:“ Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer”。
(包装动态方法)Android.Runtime.DynamicMethodNameCounter.1(intptr,intptr)上的[mono-rt]

我可以在我们的仓库中复制它,我做了类似的尝试:

if (visualElementRenderer is IDisposedState disposableRenderer && disposableRenderer.IsDisposed)
    return new SizeRequest();

但这不能解决相同的问题。

从包含CollectionView的页面导航到包含CollectionView的页面时,我在4.7.0.1179中得到了类似的东西:

LayoutPresenter.OnMeasure (System.Double widthConstraint, System.Double heightConstraint)

System.ObjectDisposedException: Cannot access a disposed object. Object name: 'Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer'.

JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) JniPeerMembers+JniInstanceMethods.InvokeNonvirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) View.get_Context () Platform.GetNativeSize (Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint) Forms+AndroidPlatformServices.GetNativeSize (Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint) VisualElement.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) LayoutPresenter.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) TemplatedView.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) Grid.MeasuredStarredColumns (System.Double widthConstraint, System.Double heightConstraint) Grid.MeasureAndContractStarredColumns (System.Double width, System.Double height, System.Double totalStarsWidth) Grid.MeasureGrid (System.Double width, System.Double height, System.Boolean requestSize) Grid.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) StackLayout.CalculateNaiveLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint) StackLayout.CalculateLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders) StackLayout.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) Layout.UpdateChildrenLayout () Layout.OnSizeAllocated (System.Double width, System.Double height) VisualElement.SizeAllocated (System.Double width, System.Double height) Layout.ResolveLayoutChanges () Thread+RunnableImplementor.Run () IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.59(intptr,intptr)

关于@samhouts的一些发现:
我们还通过CollectionView看到了这种行为。 花了一些时间之后,看来可能是由于以下事件所致。

注意:这是一个理论。

  1. 使用TemplatedItemViewHolder在ItemsViewAdapter上调用OnViewRecycled。
  2. 调用TemplatedItemViewHolder.Recycle,与TemplatedItemViewHolder关联的Xamarin.Forms.View从ItemsView中删除。
  3. TemplatedItemViewHolder被推送到RecyclerView.RecycledViewPool。
  4. 在此期间,某些事物处置了View / it的子级。
  5. 重新绑定并显示了ViewHolder,在已布置的视图上发生布局触发,并且应用程序崩溃。

我通过重写ItemsViewAdapter.OnViewRecycled并返回TemplatedItemViewHolder来解决此问题。 然后,在调用base之前,我添加了代码从OnBindViewHolder的ItemsView中删除TemplatedItemViewHolder.View。

到目前为止,没有人尝试过重现该问题

@joshuangfraedom是否可以共享适配器更改的示例代码,

@DuncWatts这样的

... 
namespace and renderer export
...
class MyCollectionViewRenderer : CollectionViewRenderer
{
        protected override GroupableItemsViewAdapter<GroupableItemsView, IGroupableItemsViewSource> CreateAdapter()
        {
            return new MyCollectionViewAdapter(ItemsView);
        }

        private class MyCollectionViewAdapter : ExtendedCollectionViewAdapter
        {
            ... base constructor call

            /// <inheritdoc />
            public override void OnViewRecycled(JObject holder)
            {
                if (holder is TemplatedItemViewHolder)
                {
                    return;
                }

                base.OnViewRecycled(holder);
            }

            /// <inheritdoc />
            public override void OnBindViewHolder(ViewHolder holder, int position)
            {
                if (holder is TemplatedItemViewHolder templatedItemViewHolder)
                {
                    ItemsView.RemoveLogicalChild(templatedItemViewHolder.View);
                }

                base.OnBindViewHolder(holder, position);
            }
        }
}

读取SelectableItemsViewAdapter看起来上面的内容会导致内存泄漏。 我们确实需要在Forms级别解决此问题,以找到适当的解决方案(该类中的所有内容都已内部化)。

这更加健壮,我认为可以按照以前的@DuncWatts @samhouts处理所有可选的东西。 我仍然不知道该如何处理Cell的渲染器。

但是将引用保留在ItemsView中似乎可以防止其被很好地清除。

    public class MyCollectionViewRenderer : ExtendedCollectionViewRenderer
    {
        private static readonly FieldInfo CurrentViewHoldersField;
        private static readonly Action<SelectableItemsViewAdapter<GroupableItemsView, IGroupableItemsViewSource>, object, int> ViewHolderClicked;
        private static readonly Func<SelectableItemsViewAdapter<GroupableItemsView, IGroupableItemsViewSource>, int, bool> PositionIsSelected;

        static MyCollectionViewRenderer()
        {
            CurrentViewHoldersField = // SelectableItemsViewAdapter._currentViewHolders via reflection
            ViewHolderClicked = // Gets SelectableItemsViewAdapter.SelectableClicked via reflection as a delegate
            PositionIsSelected =  // Gets SelectableItemsViewAdapter.PositionIsSelected via reflection as a delegate
        }

        public MyCollectionViewRenderer(Context context) : base(context)
        {
        }

        protected override GroupableItemsViewAdapter<GroupableItemsView, IGroupableItemsViewSource> CreateAdapter()
        {
            return new MyCollectionViewAdapter(
                groupableItemsView: ItemsView,
                tapColour: GetTapColour(),
                allowItemSelection: Element.SelectionMode != SelectionMode.None,
                viewAppearing: Element.ViewAppearing);
        }

        private class MyCollectionViewAdapter : GroupableItemsViewAdapter<GroupableItemsView, IGroupableItemsViewSource>
        {
            protected internal MyCollectionViewAdapter(GroupableItemsView groupableItemsView, Func<View, Context, ItemContentView> createView = null)
                : base(groupableItemsView,  createView)
            {
            }

            public override void OnViewRecycled(Java.Lang.Object holder)
            {
                // Prevent cleanup of the TemplatedItemViewHolder.
                // This cleanup looks to be the cause of the problem,
                // as it drops references to it's Xamarin Forms view.
                if (holder is TemplatedItemViewHolder templatedItemViewHolder)
                {
                    // Allows selection to be cleared in SelectableItemsViewAdapter.
                    var currentViewHolders = (List<SelectableViewHolder>)CurrentViewHoldersField.GetValue(this);
                    currentViewHolders.Remove(templatedItemViewHolder);
                    return;
                }

                base.OnViewRecycled(holder);
            }

            public override void OnBindViewHolder(ViewHolder holder, int position)
            {
                // If TemplatedItemViewHolder, do the stuff we want to do, plus the stuff forms was doing.
                // Except for SelectableItemAdapter. We don't want their events.
                // Thank you Xamarin team for using "Bind" on TemplatedItemViewHolder.
                if (holder is TemplatedItemViewHolder templatedItemViewHolder)
                {
                    // Remove the child from ItemsView, as TemplatedItemViewHolder.Bind(ItemsView) will
                    // Re-add it later on.
                    ItemsView.RemoveLogicalChild(templatedItemViewHolder.View);

                    if (ItemsSource.IsHeader(position))
                    {
                        templatedItemViewHolder.Bind(ItemsView.Header, ItemsView);
                    }
                    else if (ItemsSource.IsFooter(position))
                    {
                        templatedItemViewHolder.Bind(ItemsView.Footer, ItemsView);
                    }
                    else
                    {
                        // Also accounts for group header/group footer
                        templatedItemViewHolder.Bind(ItemsSource.GetItem(position), ItemsView);
                    }

                    // Allows selection to be cleared in SelectableItemsViewAdapter.
                    var currentViewHolders = (List<SelectableViewHolder>)CurrentViewHoldersField.GetValue(this);
                    currentViewHolders.Add(templatedItemViewHolder);

                    // Make sure that if this item is one of the selected items, it's marked as selected
                    templatedItemViewHolder.IsSelected = PositionIsSelected(this, position);
                    return;
                }

                base.OnBindViewHolder(holder, position);
            }

            public override void OnViewAttachedToWindow(JObject holder)
            {
                base.OnViewAttachedToWindow(holder);

                if (holder is TemplatedItemViewHolder templatedItemViewHolder)
                {
                    // Watch for clicks so the user can select the item held by this ViewHolder
                    // This replaces the click events triggered in SelectableItemViewHolder
                    // but still invokes SelectableItemsViewAdapter.SelectableClicked.
                    // I find these safer to use than click events when tied to Java objects.
                    templatedItemViewHolder.ItemView.SetOnClickListener(
                        ClickListener.With(
                            v => ViewHolderClicked(this, v, templatedItemViewHolder.AdapterPosition)));
                }
            }

            public override void OnViewDetachedFromWindow(JObject holder)
            {
                base.OnViewDetachedFromWindow(holder);

                if (holder is TemplatedItemViewHolder templatedItemViewHolder)
                {
                    templatedItemViewHolder.ItemView.SetOnClickListener(null);
                }
            }
        }
    }

更好的解决方案甚至是清除TemplatedItemViewHolder.Recycle上的View,然后再次执行templateChanging分支中的所有内容。 这似乎是一种更安全的方法,但是如果未在XF代码库中进行更改,则将需要重新实现一堆东西。 我不相信可以在Recycle和Bind之间保留View及其渲染器是可靠的。

我无法对此进行重现,但是在我们的应用中,原因是绑定触发了正在处置的UI(已从视觉树中移除)。
对我们来说幸运的是,只需将绑定模式设置为OneTime即可解决此问题。

我在Xamarin.Forms 4.6.0.847中遇到相同的崩溃问题。
当我用Syncfusion的SfComboBox(v18.2.0.44)弄乱了几次时,我得到了这个崩溃堆栈跟踪。 我认为其中的标签会崩溃。

@ Edgaras91我的经验也是使用syncfusion SfComboBox。 ItemTemplate上的元素将IsVisible绑定到视图模型(IsSelected)上的属性。
进行新选择时-关闭组合框下拉菜单,绑定ItemSource模型的IsSelected属性的重置导致崩溃。
将绑定模式更改为OneTime可解决此问题。

@ Edgaras91我的经验也是使用syncfusion SfComboBox。 ItemTemplate上的元素将IsVisible绑定到视图模型(IsSelected)上的属性。
进行新选择时-关闭组合框下拉菜单,绑定ItemSource模型的IsSelected属性的重置导致崩溃。
将绑定模式更改为OneTime可解决此问题。

谢谢@InquisitorJax ,但是,将DataSource绑定模型更改为OneTime并不能解决我的崩溃问题。

有关如何重现此崩溃的更多信息,可能会对其他人有所帮助:

在具有SfComboBox及其数据源中的数据的视图中,一切都是稳定的。
然后,当我使用Rg.Plugins.Popup打开一个“弹出窗口”时,重新使用与BindingContext相同的ViewModel并使其保持打开状态3秒钟,然后关闭此弹出窗口,然后通过从下拉列表中进行选择来更改原始SfComboBox的值2次,将抛出LabelRenderer异常。

我没有发布到Syncfusion的原因是纯Xamarin Forms是例外。 我尚未尝试建议的Xamarin版本回滚解决方法。

我可以确认,对我来说XF 4.4.0.991864没有修复它,仍然出现相同的异常。

Xamarin表格4.8.0.1364

JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) JniPeerMembers+JniInstanceMethods.InvokeNonvirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) View.get_Context () Platform.GetNativeSize (Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint) Forms+AndroidPlatformServices.GetNativeSize (Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint) VisualElement.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) StackLayout.CalculateNaiveLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint) StackLayout.CalculateLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders) StackLayout.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) StackLayout.CalculateNaiveLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint) StackLayout.CalculateLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders) StackLayout.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) StackLayout.CalculateNaiveLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint) StackLayout.CalculateLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders) StackLayout.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) TemplatedView.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) Grid.CalculateAutoCells (System.Double width, System.Double height) Grid.MeasureGrid (System.Double width, System.Double height, System.Boolean requestSize) Grid.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) Layout.UpdateChildrenLayout () Layout.OnSizeAllocated (System.Double width, System.Double height) VisualElement.SizeAllocated (System.Double width, System.Double height) Layout.ResolveLayoutChanges () Thread+RunnableImplementor.Run () IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this)

在带有项目模板的集合视图中可以重现此问题。 对我们来说,这已成为关键的错误。

我们有一个集合视图模板选择器,模板由可扩展组件和应用崩溃组成,单击可扩展图标后出现以下异常。

注意:只需通过设置visible false并将父网格的行大小设置为Auto即可实现扩展功能。

当可扩展视图中没有标签时,LabelRenderer不仅会引发ImageRenderer异常。

`09-10 20:20:28.104 E / AppCenterCrashes(23119):来自源的未处理异常= AndroidEnvironment
09-10 20:20:28.104 E / AppCenterCrashes(23119):System.ObjectDisposedException:无法访问已处置的对象。
09-10 20:20:28.104 E / AppCenterCrashes(23119):对象名称:“ Xamarin.Forms.Platform.Android.FastRenderers.ImageRenderer”。
09-10 20:20:28.104 E / AppCenterCrashes(23119):在Java.Interop.JniPeerMembers.AssertSelf(Java.Interop.IJavaPeerable自身)[0x00029]中0:
09-10 20:20:28.104 E / AppCenterCrashes(23119):at Java.Interop.JniPeerMembers + JniInstanceMethods.InvokeNonvirtualObjectMethod(System.String encodingMember,Java.Interop.IJavaPeerable self,Java.Interop.JniArgumentValue *参数)[0x00000]在0:
09-10 20:20:28.104 E / AppCenterCrashes(23119):在<55654ebe9f2a48e6bade2862bb243f94>:0中的Android.Views.View.get_Context()[0x0000a]
09/10 20:20:28.104 E / AppCenterCrashes(23119):位于Xa中的Xamarin.Forms.Platform.Android.Platform.GetNativeSize(Xamarin.Forms.VisualElement视图,System.Double widthConstraint,System.Double heightConstraint)[0x00019] :a1sXamarin.Forms.Platform.AndroidPlatform.cs:1341
09-10 20:20:28.104 E / AppCenterCrashes(23119):位于Xamarin.Forms.Forms + AndroidPlatformServices.GetNativeSize(Xamarin.Forms.VisualElement视图,System.Double widthConstraint,System.Double heightConstraint)[0x00000]在D:a1sXamarin中.Forms.Platform.AndroidForms.cs:921
09-10 20:20:28.104 E / AppCenterCrashes(23119):在Xamarin.Forms.VisualElement.OnSizeRequest(System.Double widthConstraint,System.Double heightConstraint)[0x00025]在D:a1sXamarin.Forms.CoreVisualElement.cs:854
09/10 20:20:28.104 E / AppCenterCrashes(23119):在Xamarin.Forms.Image.OnSizeRequest(System.Double widthConstraint,System.Double heightConstraint)[0x00000]在D:a1sXamarin.Forms.CoreImage.cs:74
09-10 20:20:28.104 E / AppCenterCrashes(23119):在Xamarin.Forms.VisualElement.OnMeasure(D.a1sXamarin.Forms.CoreVisualElement.cs:837中的System.Double widthConstraint,System.Double heightConstraint)[0x00000]
09-10 20:20:28.104 E / AppCenterCrashes(23119):在Xamarin.Forms.VisualElement.GetSizeRequest(System.Double widthConstraint,System.Double heightConstraint)[0x00053]在D:a1sXamarin.Forms.CoreVisualElement.cs:713
09-10 20:20:28.104 E / AppCenterCrashes(23119):在Xamarin.Forms.VisualElement.Measure(System.Double widthConstraint,System.Double heightConstraint,Xamarin.Forms.MeasureFlags标志)[0x00054]在D:a1sXamarin.Forms中.CoreVisualElement.cs:771
09-10 20:20:28.104 E / AppCenterCrashes(23119):在Xamarin.Forms.Grid.CalculateAutoCells(System.Double width,System.Double height)[0x002a3] in D:a1sXamarin.Forms.CoreGridCalc.cs:166
09-10 20:20:28.104 E / AppCenterCrashes(23119):在Xamarin.Forms.Grid.MeasureGrid(System.Double宽度,System.Double高度,System.Boolean requestSize)在D:a1sXamarin.Forms.CoreGridCalc中[0x0000c] .cs:576
09-10 20:20:28.104 E / AppCenterCrashes(23119):在D的Xamarin.Forms.Grid.LayoutChildren(System.Double x,System.Double y,System.Double width,System.Double height)[0x0000e]: a1sXamarin.Forms.CoreGridCalc.cs:18
09-10 20:20:28.104 E / AppCenterCrashes(23119):位于D:a1sXamarin.Forms.CoreLayout.cs:266中的Xamarin.Forms.Layout.UpdateChildrenLayout()[0x00158]
09-10 20:20:28.104 E / AppCenterCrashes(23119):在D:a1sXamarin.Forms.CoreLayout.cs:224中的Xamarin.Forms.Layout.OnSizeAllocated(System.Double width,System.Double height)[0x0000f]
09/10 20:20:28.104 E / AppCenterCrashes(23119):在Xamarin.Forms.VisualElement.SizeAllocated(System.Double width,System.Double height)[0x00000]在D:a1sXamarin.Forms.CoreVisualElement.cs:859中
09-10 20:20:28.104 E / AppCenterCrashes(23119):在D:a1sXamarin.Forms.CoreLayout.cs:392中的Xamarin.Forms.Layout.ResolveLayoutChanges()[0x0005c]
09-10 20:20:28.104 E / AppCenterCrashes(23119):位于<55654ebe9f2a48e6bade2862bb243f94>:0中的Java.Lang.Thread + RunnableImplementor.Run()[0x00008]
09-10 20:20:28.104 E / AppCenterCrashes(23119):at Java.Lang.IRunnableInvoker.n_Run(System.IntPtr jnienv,System.IntPtr native__this)[0x00008]在<55654ebe9f2a48e6bade2862bb243f94 >>:0
09-10 20:20:28.104 E / AppCenterCrashes(23119):at(wrapper dynamic-method)Android.Runtime.DynamicMethodNameCounter.1(intptr,intptr)

System.ObjectDisposedException: '无法访问已处置的对象。
对象名称:“ Xamarin.Forms.Platform.Android.FastRenderers.ImageRenderer”。

如此长时间以来,在经过如此多的投诉之后,微软如何期望使用该平台来创建具有这种基本缺陷的任何企业应用程序,这是完全荒谬的!

在过去的4个月中,我们一直无法发布应用程序Android版本的更新,而我们从此线程获得的所有信息是,当世界其他地方都可以轻松复制时,它们无法重现!!!

在修复此错误之前,Microsoft应该停止做任何事情。 发行任何较新版本的Xamarin都是毫无意义的!!!

我针对此异常的解决方法(在测试XF版本从4.5.X到4.8.X之前,请确保版本更改无效):
POV: CarouselView(作为模态)保留带有数字的标签(在购物车中选择产品数量)。 仅当用户要更改数量时,此控件才显示。 当carouselview隐藏时,此异常触发,但仍“连接”到绑定List <>和SelectedItem。
解决方案:触发Clicked事件后,立即在xaml.cs中填充此控件。 这样,此控件就不会与ViewModel / PageModel类连接。
此解决方案是绑定的模拟:
C#
// _counts是CarouselView
private void QuantityChangeTapped(object sender,System.EventArgs e)//按钮的事件
{
CartItem item =(发送者为View).BindingContext为CartItem; //购物车中要更改数量的产品
_viewModel.Item = item; //设置已经保存的数量
_counts.ItemsSource = Enumerable.Range(1,item.QuantityRemaining).ToList();
_counts.Position = item.Quantity-1; //将轮播滚动到已保存的数量
ShowSlider(); //显示轮播
}
private void CountApprouveClicked(object sender,System.EventArgs e)//名为“保存选定数量”的按钮事件
{
CloseSlider();
_viewModel.SelectedCount =(int)_counts.CurrentItem;
_viewModel.OnCountApprouve.Execute(null);
}

```

再次遇到此问题-仅涉及任何Syncfusion控件。
只是DataTemplate上具有与ViewModel绑定为IsVisible的项。
但是解决方案是相同的:将BindingMode设置为OneTime。

看到此问题的任何人都可以在这里测试nuget吗?

https://dev.azure.com/xamarin/public/_build/results?buildId=25860&view=artifacts&type=publishedArtifacts

然后,请让我知道您是否仍然看到异常?

看到此问题的任何人都可以在这里测试nuget吗?

https://dev.azure.com/xamarin/public/_build/results?buildId=25860&view=artifacts&type=publishedArtifacts

然后,请让我知道您是否仍然看到异常?

我只是尝试了您发布的块,并且不断发生异常,它与之前的异常的唯一区别是,现在引用Xamarin.Forms.Platform.Android。 Platform + DefaultRenderer

新的例外:

System.ObjectDisposedException: 'Cannot access a disposed object.
Object name: 'Xamarin.Forms.Platform.Android.Platform+DefaultRenderer'.'

旧的例外:

System.ObjectDisposedException: 'Cannot access a disposed object.
Object name: 'Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer'.'

@nacompllo您可以发布整个stacktrace吗? 我意识到可能只有一条线是不同的,但是在此处进行完整跟踪仍然很有用

@PureWeen我测试了nuget,它仍然崩溃,但是堆栈有些不同

09-12 22:30:00.522 I/MonoDroid( 5147): UNHANDLED EXCEPTION:
09-12 22:30:00.524 I/MonoDroid( 5147): System.ObjectDisposedException: Cannot access a disposed object.
09-12 22:30:00.524 I/MonoDroid( 5147): Object name: 'Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer'.
09-12 22:30:00.524 I/MonoDroid( 5147):   at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <42748fcc36b74733af2d9940a8f3cc8e>:0 
09-12 22:30:00.524 I/MonoDroid( 5147):   at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <42748fcc36b74733af2d9940a8f3cc8e>:0 
09-12 22:30:00.524 I/MonoDroid( 5147):   at Android.Views.View.get_Context () [0x0000a] in <7d2292394f8c488b97f5bc2a0ac0240d>:0 
09-12 22:30:00.524 I/MonoDroid( 5147):   at Xamarin.Forms.Platform.Android.Platform.GetNativeSize (Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint) [0x0001b] in D:\agent\1\s\Xamarin.Forms.Platform.Android\Platform.cs:1345 
09-12 22:30:00.524 I/MonoDroid( 5147):   at Xamarin.Forms.Forms+AndroidPlatformServices.GetNativeSize (Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint) [0x00001] in D:\agent\1\s\Xamarin.Forms.Platform.Android\Forms.cs:921 
09-12 22:30:00.524 I/MonoDroid( 5147):   at Xamarin.Forms.VisualElement.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x0002d] in D:\agent\1\s\Xamarin.Forms.Core\VisualElement.cs:814 
09-12 22:30:00.524 I/MonoDroid( 5147):   at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00001] in D:\agent\1\s\Xamarin.Forms.Core\VisualElement.cs:799 
09-12 22:30:00.524 I/MonoDroid( 5147):   at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00070] in D:\agent\1\s\Xamarin.Forms.Core\VisualElement.cs:689 
09-12 22:30:00.524 I/MonoDroid( 5147):   at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00064] in D:\agent\1\s\Xamarin.Forms.Core\VisualElement.cs:741 
09-12 22:30:00.524 I/MonoDroid( 5147):   at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region) [0x0009d] in D:\agent\1\s\Xamarin.Forms.Core\Layout.cs:133 
09-12 22:30:00.524 I/MonoDroid( 5147):   at Xamarin.Forms.Grid.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x00177] in D:\agent\1\s\Xamarin.Forms.Core\GridCalc.cs:49 
09-12 22:30:00.524 I/MonoDroid( 5147):   at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00173] in D:\agent\1\s\Xamarin.Forms.Core\Layout.cs:239 
09-12 22:30:00.524 I/MonoDroid( 5147):   at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x00011] in D:\agent\1\s\Xamarin.Forms.Core\Layout.cs:203 
09-12 22:30:00.524 I/MonoDroid( 5147):   at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\agent\1\s\Xamarin.Forms.Core\VisualElement.cs:817 
09-12 22:30:00.524 I/MonoDroid( 5147):   at Xamarin.Forms.Layout.ResolveLayoutChanges () [0x0008b] in D:\agent\1\s\Xamarin.Forms.Core\Layout.cs:374 
09-12 22:30:00.524 I/MonoDroid( 5147):   at Xamarin.Forms.Platform.Android.Platform+DefaultRenderer.OnMeasure (System.Int32 widthMeasureSpec, System.Int32 heightMeasureSpec) [0x00016] in D:\agent\1\s\Xamarin.Forms.Platform.Android\Platform.cs:1309 
09-12 22:30:00.524 I/MonoDroid( 5147):   at Android.Views.View.n_OnMeasure_II (System.IntPtr jnienv, System.IntPtr native__this, System.Int32 widthMeasureSpec, System.Int32 heightMeasureSpec) [0x00008] in <7d2292394f8c488b97f5bc2a0ac0240d>:0 
09-12 22:30:00.524 I/MonoDroid( 5147):   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.28(intptr,intptr,int,int)
09-12 22:30:00.532 E/AppCenterCrashes( 5147): Unhandled Exception from source=AndroidEnvironment
09-12 22:30:00.532 E/AppCenterCrashes( 5147): System.ObjectDisposedException: Cannot access a disposed object.
09-12 22:30:00.532 E/AppCenterCrashes( 5147): Object name: 'Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer'.
09-12 22:30:00.532 E/AppCenterCrashes( 5147):   at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <42748fcc36b74733af2d9940a8f3cc8e>:0 
09-12 22:30:00.532 E/AppCenterCrashes( 5147):   at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <42748fcc36b74733af2d9940a8f3cc8e>:0 
09-12 22:30:00.532 E/AppCenterCrashes( 5147):   at Android.Views.View.get_Context () [0x0000a] in <7d2292394f8c488b97f5bc2a0ac0240d>:0 
09-12 22:30:00.532 E/AppCenterCrashes( 5147):   at Xamarin.Forms.Platform.Android.Platform.GetNativeSize (Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint) [0x0001b] in D:\agent\1\s\Xamarin.Forms.Platform.Android\Platform.cs:1345 
09-12 22:30:00.532 E/AppCenterCrashes( 5147):   at Xamarin.Forms.Forms+AndroidPlatformServices.GetNativeSize (Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint) [0x00001] in D:\agent\1\s\Xamarin.Forms.Platform.Android\Forms.cs:921 
09-12 22:30:00.532 E/AppCenterCrashes( 5147):   at Xamarin.Forms.VisualElement.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x0002d] in D:\agent\1\s\Xamarin.Forms.Core\VisualElement.cs:814 
09-12 22:30:00.532 E/AppCenterCrashes( 5147):   at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00001] in D:\agent\1\s\Xamarin.Forms.Core\VisualElement.cs:799 
09-12 22:30:00.532 E/AppCenterCrashes( 5147):   at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00070] in D:\agent\1\s\Xamarin.Forms.Core\VisualElement.cs:689 
09-12 22:30:00.532 E/AppCenterCrashes( 5147):   at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00064] in D:\agent\1\s\Xamarin.Forms.Core\VisualElement.cs:741 
09-12 22:30:00.532 E/AppCenterCrashes( 5147):   at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region) [0x0009d] in D:\agent\1\s\Xamarin.Forms.Core\Layout.cs:133 
09-12 22:30:00.532 E/AppCenterCrashes( 5147):   at Xamarin.Forms.Grid.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x00177] in D:\agent\1\s\Xamarin.Forms.Core\GridCalc.cs:49 
09-12 22:30:00.532 E/AppCenterCrashes( 5147):   at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00173] in D:\agent\1\s\Xamarin.Forms.Core\Layout.cs:239 
09-12 22:30:00.532 E/AppCenterCrashes( 5147):   at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x00011] in D:\agent\1\s\Xamarin.Forms.Core\Layout.cs:203 
09-12 22:30:00.532 E/AppCenterCrashes( 5147):   at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\agent\1\s\Xamarin.Forms.Core\VisualElement.cs:817 
09-12 22:30:00.532 E/AppCenterCrashes( 5147):   at Xamarin.Forms.Layout.ResolveLayoutChanges () [0x0008b] in D:\agent\1\s\Xamarin.Forms.Core\Layout.cs:374 
09-12 22:30:00.532 E/AppCenterCrashes( 5147):   at Xamarin.Forms.Platform.Android.Platform+DefaultRenderer.OnMeasure (System.Int32 widthMeasureSpec, System.Int32 heightMeasureSpec) [0x00016] in D:\agent\1\s\Xamarin.Forms.Platform.Android\Platform.cs:1309 
09-12 22:30:00.532 E/AppCenterCrashes( 5147):   at Android.Views.View.n_OnMeasure_II (System.IntPtr jnienv, System.IntPtr native__this, System.Int32 widthMeasureSpec, System.Int32 heightMeasureSpec) [0x00008] in <7d2292394f8c488b97f5bc2a0ac0240d>:0 
09-12 22:30:00.532 E/AppCenterCrashes( 5147):   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.28(intptr,intptr,int,int)
09-12 22:30:00.539 D/Mono    ( 5147): Requesting loading reference 5 (of 6) of /storage/emulated/0/Android/data/com.Tandem.DoKapsyApp/files/.__override__/Microsoft.AppCenter.Crashes.dll
09-12 22:30:00.539 D/Mono    ( 5147): Loading reference 5 of /storage/emulated/0/Android/data/com.Tandem.DoKapsyApp/files/.__override__/Microsoft.AppCenter.Crashes.dll asmctx DEFAULT, looking for System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
09-12 22:30:00.539 D/Mono    ( 5147): Assembly Ref addref Microsoft.AppCenter.Crashes[0xec37f580] -> System.Core[0xec37e8c0]: 11
09-12 22:30:00.634 D/Mono    ( 5147): DllImport searching in: '__Internal' ('(null)').
09-12 22:30:00.634 D/Mono    ( 5147): Searching for 'java_interop_jnienv_throw'.
09-12 22:30:00.634 D/Mono    ( 5147): Probing 'java_interop_jnienv_throw'.
09-12 22:30:00.634 D/Mono    ( 5147): Found as 'java_interop_jnienv_throw'.
**System.ObjectDisposedException:** 'Cannot access a disposed object.
Object name: 'Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer'.'


=================================================================
    Native Crash Reporting
=================================================================
Got a SEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

No native Android stacktrace (see debuggerd output).

=================================================================
    Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0xe79167fa):0xe79167ea  00 00 00 c7 47 18 00 00 00 00 74 7a 8b 3a 31 d2  ....G.....tz.:1.
0xe79167fa  8b 4f 04 f7 c1 00 01 00 00 0f 84 28 f9 ff ff a8  .O.........(....
0xe791680a  01 0f 85 c1 00 00 00 8b 57 18 85 d2 0f 84 de fd  ........W.......
0xe791681a  ff ff 8b b3 04 3b 00 00 3b 93 ac fb ff ff 8b 86  .....;..;.......

=============================================================09-12 22:30:01.742 I/MonoDroid( 5147): UNHANDLED EXCEPTION:

====
    Managed Stacktrace:
=================================================================
      at <unknown> <0xffffffff>
      at Java.Interop.NativeMethods:java_interop_jnienv_new_string <0x00012>
      at Strings:NewString <0x00077>
      at Strings:NewString <0x00147>
      at Android.Runtime.JNIEnv:NewString <0x0008f>
      at Java.Lang.Error:.ctor <0x000ff>
      at Android.Runtime.JavaProxyThrowable:.ctor <0x00067>
      at Java.Lang.Throwable:FromException <0x0012f>
      at Android.Runtime.AndroidEnvironment:UnhandledException <0x0039b>
      at Android.Runtime.DynamicMethodNameCounter:28 <0x00163>
      at Android.Runtime.DynamicMethodNameCounter:28 <0x000bf>
      at <unknown> <0xffffffff>
      at Java.Interop.NativeMethods:java_interop_jnienv_call_nonvirtual_void_method_a <0x00015>
      at InstanceMethods:CallNonvirtualVoidMethod <0x00353>
      at JniInstanceMethods:InvokeNonvirtualVoidMethod <0x00127>
      at Android.Views.View:Measure <0x00197>
      at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer:OnLayout <0x0037f>
      a09-12 22:30:01.743 I/MonoDroid( 5147): System.ObjectDisposedException: Cannot access a disposed object.

t Xamarin.Forms.Platform.Android.FormsViewGroup:n_OnLayout_ZIIII <0x000ca>
      at Android.Runtime.DynamicMethodNameCounter:40 <0x00147>
      at Android.Runtime.DynamicMethodNameCounter:40 <0x000f3>
      at <unknown> <0xffffffff>
      at Java.Interop.NativeMethods:java_interop_jnienv_call_nonvirtual_void_method_a <0x00015>
      at InstanceMethods:CallNonvirtualVoidMethod <0x00353>
      at JniInstanceMethods:InvokeVirtualVoidMethod <0x002df>
      at Xamarin.Forms.Platform.Android.FormsViewGroup:MeasureAndLayout <0x00397>
      at Xamarin.Forms.Platform.Android.VisualElementTracker:UpdateLayout <0x00797>
      at Xamarin.Forms.Platform.Android.VisualElementRenderer`1:UpdateLayout <0x000c3>
      at Xamarin.Forms.Platform.Android.MasterDetailContainer:OnLayout <0x003c6>
      at Xamarin.Forms.Platform.Android.AppCompat.MasterDetailContainer:OnLayout <0x000db>
      at Android.Views.ViewGroup:n_OnLayout_ZIIII <0x000aa>
      at Android.Runtime.DynamicMethodNameCounter:27 <0x00147>
      at Android.Runtime.DynamicMethodNameCounter:27 <0x000f3>
      a09-12 22:30:01.743 I/MonoDroid( 5147): Object name: 'Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer'.

t <unknown> <0xffffffff>
      at Java.Interop.NativeMethods:java_interop_jnienv_call_nonvirtual_void_method_a <0x00015>
      at InstanceMethods:CallNonvirtualVoidMethod <0x00353>
      at JniInstanceMethods:InvokeVirtualVoidMethod <0x002df>
      at AndroidX.DrawerLayout.Widget.DrawerLayout:OnLayout <0x002eb>
      at Xamarin.Forms.Platform.Android.AppCompat.MasterDetailPageRenderer:OnLayout <0x00087>
      at AndroidX.DrawerLayout.Widget.DrawerLayout:n_OnLayout_ZIIII <0x000aa>
      at Android.Runtime.DynamicMethodNameCounter:31 <0x00147>
      at Android.Runtime.DynamicMethodNameCounter:31 <0x000f3>
      at <unknown> <0xffffffff>
      at Java.Interop.NativeMethods:java_interop_jnienv_call_nonvirtual_void_method_a <0x00015>
      at InstanceMethods:CallNonvirtualVoidMethod <0x00353>
      at JniInstanceMethods:InvokeNonvirtualVoidMethod <0x00127>
      at Android.Views.ViewGroup:Layout <0x00277>
      at Xamarin.Forms.Platform.Android.VisualElementTracker:UpdateLayout <0x0061a>
      at Xamarin.Forms.Platform.Android.AppCompat.MasterDetailPageRende09-12 22:30:01.743 I/MonoDroid( 5147):   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.28(intptr,intptr,int,int)

rer:Xamarin.Forms.Platform.Android.IVisualElementRenderer.UpdateLayout <0x00067>
      at Xamarin.Forms.Platform.Android.AppCompat.Platform:Xamarin.Forms.Platform.Android.IPlatformLayout.OnLayout <0x00184>
      at Xamarin.Forms.Platform.Android.PlatformRenderer:OnLayout <0x00119>
      at Android.Views.ViewGroup:n_OnLayout_ZIIII <0x000aa>
      at Android.Runtime.DynamicMethodNameCounter:27 <0x00147>
      at Android.Runtime.DynamicMethodNameCounter:27 <0x000f3>
=================================================================09-12 22:30:01.743 I/MonoDroid( 5147):   at (wrapper native-to-managed) Android.Runtime.DynamicMethodNameCounter.28(intptr,intptr,int,int)

09-12 22:30:01.743 I/MonoDroid( 5147):   at (wrapper managed-to-native) Java.Interop.NativeMethods.java_interop_jnienv_call_nonvirtual_void_method_a(intptr,intptr&,intptr,intptr,intptr,intptr)
09-12 22:30:01.743 I/MonoDroid( 5147):   at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00079] in <42748fcc36b74733af2d9940a8f3cc8e>:0 
09-12 22:30:01.743 I/MonoDroid( 5147):   at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0001f] in <42748fcc36b74733af2d9940a8f3cc8e>:0 
09-12 22:30:01.743 I/MonoDroid( 5147):   at Android.Views.View.Measure (System.Int32 widthMeasureSpec, System.Int32 heightMeasureSpec) [0x00035] in <7d2292394f8c488b97f5bc2a0ac0240d>:0 
09-12 22:30:01.743 I/MonoDroid( 5147):   at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer+Container.OnMeasure (System.Int32 widthMeasureSpec, System.Int32 heightMeasureSpec) [0x000d0] in D:\agent\1\s\Xamarin.Forms.Platform.Android\AppCompat\NavigationPageRenderer.cs:1223 
09-12 22:30:01.743 I/MonoDroid( 5147):   at Android.Views.View.n_OnMeasure_II (System.IntPtr jnienv, System.IntPtr native__this, System.Int32 widthMeasureSpec, System.Int32 heightMeasureSpec) [0x00008] in <7d2292394f8c488b97f5bc2a0ac0240d>:0 
09-12 22:30:01.743 I/MonoDroid( 5147):   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.28(intptr,intptr,int,int)
09-12 22:30:01.746 F/libc    ( 5147): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x6f726578 in tid 5147 (ndem.DoKapsyApp), pid 5147 (ndem.DoKapsyApp)
[HotReload] (2020-09-12 22:30:03.9): INFO: (Tandem.DoKapsyApp.Android) Stopped Hot Reload session due to ExplicitlyEnded ...

@PureWeen
我附上从输出窗口获得的所有信息:

09-13 12:37:30.755 I / MonoDroid(21323):意外的例外:
09-13 12:37:30.758 I / MonoDroid(21323):System.ObjectDisposedException:无法访问已处置的对象。
09-13 12:37:30.759 I / MonoDroid(21323):对象名称:“ Xamarin.Forms.Platform.Android.Platform + DefaultRenderer”。
09-13 12:37:30.759 I / MonoDroid(21323):at(包装动态方法)Android.Runtime.DynamicMethodNameCounter.33(intptr,intptr,bool,int,int,int,int)
09-13 12:37:30.759 I / MonoDroid(21323):at(wrapper native-to-managed)Android.Runtime.DynamicMethodNameCounter.33(intptr,intptr,int,int,int,int,int)
09-13 12:37:30.759 I / MonoDroid(21323):at(wrappermanaged-to-native)Java.Interop.NativeMethods.java_interop_jnienv_call_nonvirtual_void_method_a(intptr,intptr&,intptr,intptr,intptr,intptr)
09-13 13:37:30.759 I / MonoDroid(21323):在Java.Interop.JniEnvironment + InstanceMethods.CallNonvirtualVoidMethod(Java.Interop.JniObjectReference实例,Java.Interop.JniObjectReference类型,Java.Interop.JniMethodInfo方法,Java.Interop .JniArgumentValue * args)[0x00079]在<42748fcc36b74733af2d9940a8f3cc8e>:0中
09-13 12:37:30.759 I / MonoDroid(21323):在Java.Interop.JniPeerMembers + JniInstanceMethods.InvokeVirtualVoidMethod(System.String编码的成员,Java.Interop.IJavaPeerable自我,Java.Interop.JniArgumentValue *参数)[0x0005d]在<42748fcc36b74733af2d9940a8f3cc8e>:0
09-13 12:37:30.759 I / MonoDroid(21323):位于Xamarin.Forms.Platform.Android.FormsViewGroup.MeasureAndLayout(System.Int32 p0,System.Int32 p1,System.Int32 p2,System.Int32 p3,System。 D:agent1sXamarin.Forms.Platform.Android.FormsViewGroupobjDebuggenicsrcXamarin.Forms.Platform.Android.FormsViewGroup.cs:181中的Int32 p4,System.Int32 p5)[0x00088]
09/13 12:37:30.759 I / MonoDroid(21323):在Xamarin.Forms.Platform.Android.VisualElementTracker.UpdateLayout()在D:agent1sXamarin.Forms.Platform.AndroidVisualElementTracker.cs:111 [0x0015c]
09/13 12:37:30.759 I / MonoDroid(21323):在Xamarin.Forms.Platform.Android.VisualElementRenderer`1 [TElement] .UpdateLayout()在D:agent1sXamarin.Forms.Platform.AndroidVisualElementRenderer.cs: 139
09-13 12:37:30.759 I / MonoDroid(21323):位于Xamarin.Forms.Platform.Android.AppCompat.Platform.Xamarin.Forms.Platform.Android.IPlatformLayout.OnLayout(更改了System.Boolean,System.Int32 l, D:agent1sXamarin.Forms.Platform.AndroidAppCompatPlatform.cs:235中的System.Int32 t,System.Int32 r,System.Int32 b)[0x0002f]
09-13 12:37:30.759 I / MonoDroid(21323):位于Xamarin.Forms.Platform.Android.PlatformRenderer.OnLayout(System.Boolean已更改,System.Int32 l,System.Int32 t,System.Int32 r,System。 Int32 b)D:agent1sXamarin.Forms.Platform.AndroidPlatformRenderer.cs:75中的[0x0001d]
09-13 12:37:30.759 I / MonoDroid(21323):在Android.Views.ViewGroup.n_OnLayout_ZIIII(System.IntPtr jnienv,System.IntPtr native__this,System.Boolean已更改,System.Int32 l,System.Int32 t,System .int32 r,System.Int32 b)<7d2292394f8c488b97f5bc2a0ac0240d>:0中的[0x00008]
09-13 12:37:30.759 I / MonoDroid(21323):at(包装动态方法)Android.Runtime.DynamicMethodNameCounter.27(intptr,intptr,bool,int,int,int,int)
System.ObjectDisposedException: '无法访问已处置的对象。
对象名称:“ Xamarin.Forms.Platform.Android.Platform + DefaultRenderer”。

09-13 12:37:33.822 E / mono(21323):
09-13 12:37:33.822 E / mono(21323):未处理的异常:
09-13 12:37:33.822 E / mono(21323):System.ObjectDisposedException:无法访问已处置的对象。
09-13 12:37:33.822 E / mono(21323):对象名称:“ Xamarin.Forms.Platform.Android.Platform + DefaultRenderer”。
09-13 12:37:33.822 E / mono(21323):at(包装动态方法)Android.Runtime.DynamicMethodNameCounter.33(intptr,intptr,bool,int,int,int,int)
09-13 12:37:33.822 E / mono(21323):at(wrapper native-to-managed)Android.Runtime.DynamicMethodNameCounter.33(intptr,intptr,int,int,int,int,int,int)
09-13 12:37:33.822 E / mono(21323):at(wrappermanaged-to-native)Java.Interop.NativeMethods.java_interop_jnienv_call_nonvirtual_void_method_a(intptr,intptr&,intptr,intptr,intptr,intptr)
09-13 12:37:33.822 E / mono(21323):at Java.Interop.JniEnvironment + InstanceMethods.CallNonvirtualVoidMethod(Java.Interop.JniObjectReference实例,Java.Interop.JniObjectReference类型,Java.Interop.JniMethodInfo方法,Java.Interop .JniArgumentValue * args)[0x00079]在<42748fcc36b74733af2d9940a8f3cc8e>:0中
09-13 12:37:33.822 E / mono(21323):at Java.Interop.JniPeerMembers + JniInstanceMethods.InvokeVirtualVoidMethod(System.String encodingMember,Java.Interop.IJavaPeerable self,Java.Interop.JniArgumentValue *参数)[0x0005d]在<42748fcc36b74733af2d9940a8f3cc8e>:0
09-13 12:37:33.822 E / mono(21323):在Xamarin.Forms.Platform.Android.FormsViewGroup.MeasureAndLayout(System.Int32 p0,System.Int32 p1,System.Int32 p2,System.Int32 p3,System。 D:agent1sXamarin.Forms.Platform.Android.FormsViewGroupobjDebuggenicsrcXamarin.Forms.Platform.Android.FormsViewGroup.cs:181中的Int32 p4,System.Int32 p5)[0x00088]
09-13 12:37:33.822 E / mono(21323):在D:agent1sXamarin.Forms.Platform.AndroidVisualElementTracker.cs:111中的Xamarin.Forms.Platform.Android.VisualElementTracker.UpdateLayout()[0x0015c]
09-13 12:37:33.822 E / mono(21323):在Xamarin.Forms.Platform.Android.VisualElementRenderer 1[TElement].UpdateLayout () [0x00014] in D:\agent\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:139 09-13 12:37:33.822 E/mono (21323): at Xamarin.Forms.Platform.Android.AppCompat.Platform.Xamarin.Forms.Platform.Android.IPlatformLayout.OnLayout (System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x0002f] in D:\agent\1\s\Xamarin.Forms.Platform.Android\AppCompat\Platform.cs:235 09-13 12:37:33.822 E/mono (21323): at Xamarin.Forms.Platform.Android.PlatformRenderer.OnLayout (System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x0001d] in D:\agent\1\s\Xamarin.Forms.Platform.Android\PlatformRenderer.cs:75 09-13 12:37:33.822 E/mono (21323): at Android.Views.ViewGroup.n_OnLayout_ZIIII (System.IntPtr jnienv, System.IntPtr native__this, System.Boolean changed, System.Int32 l, System.Int32 t, System.Int32 r, System.Int32 b) [0x00008] in <7d2292394f8c488b97f5bc2a0ac0240d>:0 09-13 12:37:33.822 E/mono (21323): at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.27(intptr,intptr,bool,int,int,int,int) 09-13 12:37:33.822 E/mono (21323): --- End of stack trace from previous location where exception was thrown --- 09-13 12:37:33.822 E/mono (21323): 09-13 12:37:33.822 E/mono (21323): at Java.Interop.JniEnvironment+Strings.NewString (System.Char* unicodeChars, System.Int32 length) [0x0001e] in <42748fcc36b74733af2d9940a8f3cc8e>:0 09-13 12:37:33.822 E/mono (21323): at Java.Interop.JniEnvironment+Strings.NewString (System.String value) [0x00024] in <42748fcc36b74733af2d9940a8f3cc8e>:0 09-13 12:37:33.822 E/mono (21323): at Android.Runtime.JNIEnv.NewString (System.String text) [0x00009] in <7d2292394f8c488b97f5bc2a0ac0240d>:0 09-13 12:37:33.822 E/mono (21323): at Java.Lang.Error..ctor (System.String message) [0x0001f] in <7d2292394f8c488b97f5bc2a0ac0240d>:0 09-13 12:37:33.822 E/mono (21323): at Android.Runtime.JavaProxyThrowable..ctor (System.Exception innerException) [0x00007] in <7d2292394f8c488b97f5bc2a0ac0240d>:0 09-13 12:37:33.822 E/mono (21323): at Java.Lang.Throwable.FromException (System.Exception e) [0x0001d] in <7d2292394f8c488b97f5bc2a0ac0240d>:0 09-13 12:37:33.822 E/mono (21323): at Android.Runtime.AndroidEnvironment.UnhandledException (System.Exception e) [0x00067] in <7d2292394f8c488b97f5bc2a0ac0240d>:0 09-13 12:37:33.822 E/mono (21323): at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.27(intptr,intptr,bool,int,int,int,int) 09-13 12:37:33.822 E/mono (21323): at (wrapper native-to-managed) Android.Runtime.DynamicMethodNameCounter.27(intptr,intptr,int,int,int,int,int) 09-13 12:37:33.826 E/mono-rt (21323): [ERROR] FATAL UNHANDLED EXCEPTION: System.ObjectDisposedException: Cannot access a disposed object. 09-13 12:37:33.826 E/mono-rt (21323): Object name: 'Xamarin.Forms.Platform.Android.Platform+DefaultRenderer'. 09-13 12:37:33.826 E/mono-rt (21323): at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.33(intptr,intptr,bool,int,int,int,int) 09-13 12:37:33.826 E/mono-rt (21323): at (wrapper native-to-managed) Android.Runtime.DynamicMethodNameCounter.33(intptr,intptr,int,int,int,int,int) 09-13 12:37:33.826 E/mono-rt (21323): at (wrapper managed-to-native) Java.Interop.NativeMethods.java_interop_jnienv_call_nonvirtual_void_method_a(intptr,intptr&,intptr,intptr,intptr,intptr) 09-13 12:37:33.826 E/mono-rt (21323): at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00079] in <42748fcc36b74733af2d9940a8f3cc8e>:0 09-13 12:37:33.826 E/mono-rt (21323): at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0005d] in <42748fcc36b74733af2d9940a8f3cc8e>:0 09-13 12:37:33.826 E/mono-rt (21323): at Xamarin.Forms.Platform.Android.FormsViewGroup.MeasureAndLayout (System.Int32 p0, System.Int32 p1, System.Int32 p2, System.Int32 p3, System.Int32 p4, System.Int32 p5) [0x00088] in D:\agent\1\s\Xamarin.Forms.Platform.Android.FormsViewGroup\obj\Debug\generated\src\Xamarin.Forms.Platform.Android.FormsViewGroup.cs:181 09-13 12:37:33.826 E/mono-rt (21323): at Xamarin.Forms.Platform.Android.VisualElementTracker.UpdateLayout () [0x0015c] in D:\agent\1\s\Xamarin.Forms.Platform.Android\VisualElementTracker.cs:111 09-13 12:37:33.826 E/mono-rt (21323): at Xamarin.Forms.Platform.Android.VisualElementRenderer 1 [TElement] .UpdateLayout()在D:agent1sXamarin.Forms.Platform中[0x00014] .AndroidVisualElementRenderer.cs:139
09-13 12:37:33.826 E / mono-rt(21323):在Xamarin.Forms.Platform.Android.AppCompat.Platform.Xamarin.Forms.Platform.Android.IPlatformLayout.OnLayout(System.Boolean已更改,System.Int32 l,System.Int32 t,System.Int32 r,System.Int32 b)D:agent1sXamarin.Forms.Platform.AndroidAppCompatPlatform.cs:235中的[0x0002f]
09-13 12:37:33.826 E / mono-rt(21323):位于Xamarin.Forms.Platform.Android.PlatformRenderer.OnLayout(System.Boolean已更改,System.Int32 l,System.Int32 t,System.Int32 r, D:agent1sXamarin.Forms.Platform.AndroidPlatformRenderer.cs:75中的System.Int32 b)[0x0001d]
09-13 12:37:33.826 E / mono-rt(21323):在Android.Views.ViewGroup.n_OnLayout_ZIIII(System.IntPtr jnienv,System.IntPtr native__this,System.Boolean已更改,System.Int32 l,System.Int32 t ,System.Int32 r,System.Int32 b)<7d2292394f8c488b97f5bc2a0ac0240d>:0中的[0x00008]
09-13 12:37:33.826 E / mono-rt(21323):at(包装动态方法)Android.Runtime.DynamicMethodNameCounter.27(intptr,intptr,bool,int,int,int,int)
09-13 12:37:33.826 E / mono-rt(21323):-从上一个引发异常的位置开始的堆栈跟踪结束-
09-13 12:37:33.826 E / mono-rt(21323):
09-13 13:37:33.826 E / mono-rt(21323):在Java.Interop.JniEnvironment + Strings.NewString(System.Char * unicodeChars,System.Int32长度)[0x0001e]在<42748fcc36b74733af2d9940a8f3cc8e>:0中
09-13 12:37:33.826 E / mono-rt(21323):在<42748fcc36b74733af2d9940a8f3cc8e>:0中的Java.Interop.JniEnvironment + Strings.NewString(System.String值)[0x00024]
09-13 12:37:33.826 E / mono-rt(21323):在<7d2292394f8c488b97f5bc2a0ac0240d>:0中的Android.Runtime.JNIEnv.NewString(System.String文本)[0x00009]
09-13 12:37:33.826 E / mono-rt(21323):位于<7d2292394f8c488b97f5bc2a0ac0240d>:0中的Java.Lang.Error..ctor(System.String消息)[0x0001f]
09-13 12:37:33.826 E / mono-rt(21323):在<7d2292394f8c488b97f5bc2a0ac0240d>:0中的Android.Runtime.JavaProxyThrowable..ctor(System.Exception innerException)[0x00007]
09-13 12:37:33.826 E / mono-rt(21323):位于<7d2292394f8c488b97f5bc2a0ac0240d>:0中的Java.Lang.Throwable.FromException(System.Exception e)[0x0001d]
09-13 12:37:33.826 E / mono-rt(21323):在Android.Runtime.AndroidEnvironment.UnhandledException(System.Exception e)[0x00067]在<7d2292394f8c488b97f5bc2a0ac0240d>:0中
09-13 12:37:33.826 E / mono-rt(21323):at(包装动态方法)Android.Runtime.DynamicMethodNameCounter.27(intptr,intptr,bool,int,int,int,int)终止

09-13 12:37:33.826 E / mono-rt(21323):at(wrapper native-to-managed)Android.Runtime.DynamicMethodNameCounter.27(intptr,intptr,int,int,int,int,int)
09-13 12:37:33.865 E / libc ++ abi(21323):终止
09-13 12:37:33.866 F / libc(21323):致命信号6(SIGABRT),tid 21323(ame.labelrender)中的代码-1(SI_QUEUE),pid 21323(ame.labelrender)

@nacompllo @Reveon

试试这个,让我知道!

https://dev.azure.com/xamarin/public/_build/results?buildId=26573&view=artifacts&type=publishedArtifacts

@PureWeen
我只是用新的nuget进行了测试,似乎问题已解决,不再重现,似乎该nuget解决了此问题。 辛苦了

@PureWeen我做了一个快速测试,看来异常消失了

@PureWeen我也确认,在快速测试之后,我的应用目前没有触发此异常。

太棒了!!

@PureWeen ,提供的nuget不再发生异常。 传说。

有人可以解释如何将此“ nuget”安装到Xamarin Forms吗?

@ Edgaras91看看这个

@ Edgaras91
点击链接。
在“ nuget”面板的右侧,将有“更多”按钮(3个垂直点),从上下文菜单中选择“下载”。
然后在系统文件(例如“ C:reposlocalNugets”)中设置(如@Reveon所述)本地
然后在您的VS中打开NuGet管理器,并从此组合框中
obraz
选择您的本地来源(我的称为“本地”)
最后,像往常一样将Xamarin.Forms安装/更新到所选项目。

谢谢@Reveon@BartoszKopec 。 但是,我还拥有Dev Ops的持续集成,这会很有趣。

@ Edgaras91我将App Center用作CI,并且

也可以确认这个看起来要解决。
@PureWeen我们是否知道此发行计划的eta或多或少是什么?

  • 大功告成,顺便说一句;)

你好
对于有此问题的人:在我的情况下,我有几个Label通过IsVisible更改了可见性。
我将其更改为BackGroundColorTextColor是否为Color.Transparent ,问题消失了……
希望这可以帮助 ...

此修复程序将包含在下一个4.8中吗? 还是5.0?

下一个SR为4.8

4.8.0.1451上的相同例外:

{InnerException: null  StackTrace:   at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <324349c9a2dd47568c91620d2bd3db5a>:0 
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <324349c9a2dd47568c91620d2bd3db5a>:0 
  at Android.Views.View.get_Context () [0x0000a] in <f69f42e19d884caca4279f1717610a26>:0 
  at Xamarin.Forms.Platform.Android.Platform.GetNativeSize (Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint) [0x00019] in D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:1341 
  at Xamarin.Forms.Forms+AndroidPlatformServices.GetNativeSize (Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\Forms.cs:921 
  at Xamarin.Forms.VisualElement.OnSizeRequest (Syst


    at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <324349c9a2dd47568c91620d2bd3db5a>:0 
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <324349c9a2dd47568c91620d2bd3db5a>:0 
  at Android.Views.View.get_Context () [0x0000a] in <f69f42e19d884caca4279f1717610a26>:0 
  at Xamarin.Forms.Platform.Android.Platform.GetNativeSize (Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint) [0x00019] in D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:1341 
  at Xamarin.Forms.Forms+AndroidPlatformServices.GetNativeSize (Xamarin.Forms.VisualElement view, System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\Forms.cs:921 
  at Xamarin.Forms.VisualElement.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00025] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:811 
  at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:796 
  at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:686 
  at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:738 
  at Xamarin.Forms.StackLayout.CalculateNaiveLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint) [0x00236] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:198 
  at Xamarin.Forms.StackLayout.CalculateLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders) [0x00058] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:123 
  at Xamarin.Forms.StackLayout.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00019] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:80 
  at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:796 
  at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:686 
  at Xamarin.Forms.Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:113 
  at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:738 
  at Xamarin.Forms.StackLayout.CalculateNaiveLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, Xamarin.Forms.StackOrientation orientation, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint) [0x000a8] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:163 
  at Xamarin.Forms.StackLayout.CalculateLayout (Xamarin.Forms.StackLayout+LayoutInformation layout, System.Double x, System.Double y, System.Double widthConstraint, System.Double heightConstraint, System.Boolean processExpanders) [0x00058] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:123 
  at Xamarin.Forms.StackLayout.OnSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00019] in D:\a\1\s\Xamarin.Forms.Core\StackLayout.cs:80 
  at Xamarin.Forms.VisualElement.OnMeasure (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:796 
  at Xamarin.Forms.VisualElement.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00053] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:686 
  at Xamarin.Forms.Layout.GetSizeRequest (System.Double widthConstraint, System.Double heightConstraint) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:113 
  at Xamarin.Forms.VisualElement.Measure (System.Double widthConstraint, System.Double heightConstraint, Xamarin.Forms.MeasureFlags flags) [0x00054] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:738 
  at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region) [0x0007b] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:133 
  at Xamarin.Forms.TemplatedView.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x00019] in D:\a\1\s\Xamarin.Forms.Core\TemplatedView.cs:29 
  at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00158] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:239 
  at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:203 
  at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:814 
  at Xamarin.Forms.Layout.ResolveLayoutChanges () [0x0005c] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:362 
  at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <f69f42e19d884caca4279f1717610a26>:0 
  at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <f69f42e19d884caca4279f1717610a26>:0 
  at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.36(intptr,intptr)


  Cannot access a disposed object.
Object name: 'Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer'.


Xamarin.Forms.Platform.Android.FastRenderers.LabelRenderer

Java.Interop

System.ObjectDisposedException

它不在该发行版中,您需要等待Xamarin表格4.8 Service Release 3

它不在该发行版中,您需要等待Xamarin表格4.8 Service Release 3

@joshuangfraedom您的意思是此问题已在Xamarin表格4.8 Service Release 3中得到解决?

计划什么时候出版? 要等多久 ... :-)))

我不确定是否很抱歉,如果您愿意的话,此修补程序当前在XF 5.0 Prerelease 1中。 @samhouts我们能否获得4.8的另一个服务版本的更新?

我测试了一个具有相同错误Xamarin 5.0.0.1539-pre2的项目,但该项目仍然存在

System.ObjectDisposedException: Cannot access a dropped object

在项目中使用此行Forms.SetFlags ("UseLegacyRenderers")例外具有ObjectName:
Xamarin.Forms.Platform.Android.AppCompat.FrameRenderer

没有标志行的ObjectName:
Xamarin.Forms.Platform.Android.FastRenderers.FrameRenderer

@TsplayerT您可以发布完整的堆栈跟踪信息吗?

这里是:

| 主线| 详情|
| ------------------- | ------------------- |
| Java.Interop | JniPeerMembers.AssertSelf(Java.Interop.IJavaPeerable自我)| Java
| Java.Interop | JniPeerMembers + JniInstanceMethods.InvokeVirtualVoidMethod(System.String编码的成员,Java.Interop.IJavaPeerable自我,Java.Interop.JniArgumentValue *参数)|
| Android.Views | View.set_Enabled(System.Boolean值)|
| Xamarin.Forms.Platform.Android.FastRenderers | VisualElementRenderer.UpdateIsEnabled()|
| Xamarin.Forms.Platform.Android.FastRenderers | VisualElementRenderer.OnElementPropertyChanged(System.Object sender,System.ComponentModel.PropertyChangedEventArgs e)(包装委托调用.invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)|
| Xamarin.Forms | BindableObject.OnPropertyChanged(System.String propertyName)
| Xamarin.Forms | Element.OnPropertyChanged(System.String propertyName)
| Xamarin.Forms | BindableObject.SetValueActual(Xamarin.Forms.BindableProperty属性,Xamarin.Forms.BindableObject + BindablePropertyContext上下文,System.Object值,System.Boolean当前正在应用,Xamarin.Forms.Internals.SetValueFlags属性,System.Boolean无提示)|
| Xamarin.Forms | BindableObject.SetValueCore(Xamarin.Forms.BindableProperty属性,System.Object值,Xamarin.Forms.Internals.SetValueFlags属性,Xamarin.Forms.BindableObject + SetValuePrivateFlags privateAttributes)|
| Xamarin.Forms | BindingExpression.ApplyCore(System.Object sourceObject,Xamarin.Forms.BindableObject目标,Xamarin.Forms.BindableProperty属性,System.Boolean fromTarget)|
| Xamarin.Forms | BindingExpression.Apply(System.Boolean fromTarget)|
| Xamarin.Forms | BindingExpression + BindingExpressionPart。b__49_0()|
| Java.Lang | Thread + RunnableImplementor.Run()|
| Java.Lang | IRunnableInvoker.n_Run(System.IntPtr jnienv,System.IntPtr native__this)(包装动态方法)Android.Runtime.DynamicMethodNameCounter.24(intptr,intptr)|

错误的详细信息和其他信息附后。 report.txt

这应该重新打开。 我也可以在5.0.0.1558-pre3上重现它。
请记住,我遇到以下情况-框架内有几个元素(包括标签)。 我已经将Frame封装在自己的类-TestFrame中。 在那里,我重写了OnElementPropertyChanged。 当我收到“ Y”属性的属性更改事件时,会发生异常。 请记住,偶尔,我会在LabelRenderer本身而不是Frame中遇到异常。 我想问题仍然存在,只是在这种情况下,当我们有一个框架时就会出现。 这是堆栈跟踪:

System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Test.Droid.Renderers.TestFrameRenderer'.
  at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in <42748fcc36b74733af2d9940a8f3cc8e>:0 
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeNonvirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in <42748fcc36b74733af2d9940a8f3cc8e>:0 
  at Android.Views.View.get_Context () [0x0000a] in <7d2292394f8c488b97f5bc2a0ac0240d>:0 
  at Test.Droid.Renderers.TestFrameRenderer.UpdateFrame (Test.Views.Controls.TestFrame frameElement) [0x00001] in ...Test.Android\Renderers\TestFrameRenderer.cs:50 
  at Test.Droid.Renderers.TestFrameRenderer.OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x0001f] in ...\Test.Android\Renderers\TestFrameRenderer.cs:44 
  at (wrapper delegate-invoke) <Module>.invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
  at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:229 
  at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:362 
  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) [0x00114] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:464 
  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:400 
  at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x00042] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:335 
  at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindablePropertyKey propertyKey, System.Object value) [0x0000e] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:319 
  at Xamarin.Forms.VisualElement.set_Y (System.Double value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:556 
  at Xamarin.Forms.VisualElement.set_Bounds (Xamarin.Forms.Rectangle value) [0x00050] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:408 
  at Xamarin.Forms.VisualElement.Layout (Xamarin.Forms.Rectangle bounds) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:779 
  at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion (Xamarin.Forms.VisualElement child, Xamarin.Forms.Rectangle region) [0x001da] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:157 
  at Xamarin.Forms.Grid.LayoutChildren (System.Double x, System.Double y, System.Double width, System.Double height) [0x00144] in D:\a\1\s\Xamarin.Forms.Core\GridCalc.cs:49 
  at Xamarin.Forms.Layout.UpdateChildrenLayout () [0x00158] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:239 
  at Xamarin.Forms.Layout.OnSizeAllocated (System.Double width, System.Double height) [0x0000f] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:203 
  at Xamarin.Forms.VisualElement.SizeAllocated (System.Double width, System.Double height) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\VisualElement.cs:869 
  at Xamarin.Forms.Layout.ResolveLayoutChanges () [0x00069] in D:\a\1\s\Xamarin.Forms.Core\Layout.cs:374 
  at Xamarin.Forms.Platform.Android.Platform+DefaultRenderer.OnMeasure (System.Int32 widthMeasureSpec, System.Int32 heightMeasureSpec) [0x0000f] in D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:1319 
  at Android.Views.View.n_OnMeasure_II (System.IntPtr jnienv, System.IntPtr native__this, System.Int32 widthMeasureSpec, System.Int32 heightMeasureSpec) [0x00008] in <7d2292394f8c488b97f5bc2a0ac0240d>:0 
  at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.36(intptr,intptr,int,int)

@mduchev我意识到异常名称是相同的,但是这种类型的异常就像NullReferenceException。 每个人都有不同的原因。 您所拥有的一个将与此无关。

如果您可以通过repro创建新问题,这将对您有所帮助

@mduchev您是否在4.8中看到异常?

@mduchev我注意到您的异常来自自定义渲染器

如果仅使用我们的渲染器,还会看到相同的异常吗?

您可能需要检查是否已处置FrameRenderer,而不调用此代码

at Test.Droid.Renderers.TestFrameRenderer.UpdateFrame (Test.Views.Controls.TestFrame frameElement) [0x00001] in ...Test.Android\Renderers\TestFrameRenderer.cs:50 
  at Test.Droid.Renderers.TestFrameRenderer.OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x0001f] in ...\Test.Android\Renderers\TestFrameRenderer.cs:44 

@PureWeen这可能是另一个问题,不能肯定地说。 我看到了ObjectDisposedException,而且就像我说的那样,偶尔会出现FastRenderers.LabelRenderer的ObjectDisposedException异常(对于相同的流程!)。
不幸的是,我无法上传副本。 我将尝试创建一个并用包装标签的框架对其进行测试。
我只是尝试了4.8.0.1560,那里是例外。 我还用4.7.0.1351和5.0.0.1558-pre3测试并确认了它。

@mduchev还是有人知道为什么将发布Xamarin版本5,说明此问题已解决但仍在发生? 我听不懂

即使在项目中使用此行Forms.SetFlags (" UseLegacyRenderers ") ,ObjectName也会发生异常:
Xamarin.Forms.Platform.Android.AppCompat.FrameRenderer

没有要标记的行,该异常具有以下ObjectName:
Xamarin.Forms.Platform.Android.FastRenderers.FrameRenderer

@TsplayerT我认为我们俩都看到的问题(FrameRenderer异常)是一个单独的问题。 主要问题-具有LabelRenderer的那个确实可以解决,但是FrameRenderer发生了类似的错误。 我还注意到只有在框架内使用某些东西时,才会出现新的异常。 不幸的是,我无法查明导致应用崩溃的确切布局和步骤。 如果可以的话,请提供一个示例项目并针对框架异常打开新的版本。

@ZeProgFactory感谢您为像我这样的人提供的完美解决方法,他们由于许多问题而无法更新到最新的Xamarin版本,这些问题甚至有待添加到特定的sprint中。

此页面是否有帮助?
0 / 5 - 0 等级