Xamarin.Forms.Platform.Android.Platform+DefaultRenderer 来自本机句柄

编程入门 行业动态 更新时间:2024-10-23 15:30:32
本文介绍了Xamarin.Forms.Platform.Android.Platform+DefaultRenderer 来自本机句柄的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在使用 xamarin 表单在 android 上开发应用程序.几天以来,我遇到了以下问题.

I am developing app on android using xamarin forms. Since few days, I am getting below issue.

CurrentDomainOnUnhandledException ---> System.NotSupportedException:无法激活类型的实例来自本机的 Xamarin.Forms.Platform.Android.Platform+DefaultRenderer句柄 0xbeb0861c (key_handle 0xb3a225b).--->System.MissingMethodException:找不到构造函数Xamarin.Forms.Platform.Android.Platform+DefaultRenderer::.ctor(System.IntPtr,Android.Runtime.JniHandleOwnership) --->Java.Interop.JavaLocationException:类型异常'Java.Interop.JavaLocationException' 被抛出.05-02 14:36:57.973I/mono-stdout(16628): System.Exception:CurrentDomainOnUnhandledException ---> System.NotSupportedException:无法激活类型的实例来自本机的 Xamarin.Forms.Platform.Android.Platform+DefaultRenderer句柄 0xbeb0861c (key_handle 0xb3a225b).--->System.MissingMethodException:找不到构造函数Xamarin.Forms.Platform.Android.Platform+DefaultRenderer::.ctor(System.IntPtr,Android.Runtime.JniHandleOwnership) --->Java.Interop.JavaLocationException:类型异常'Java.Interop.JavaLocationException' 被抛出.--- 内部结束异常堆栈跟踪 --- 05-02 14:36:57.975 I/mono-stdout(16628):
--- 内部异常堆栈跟踪结束 --- 在 Java.Interop.TypeManager.CreateProxy(System.Type 类型,System.IntPtr句柄,Android.Runtime.JniHandleOwnership 转移)[0x00054] 中:0 05-02 14:36:57.978I/mono-stdout(16628):在 Java.Interop.TypeManager.CreateProxy(System.Type 类型,System.IntPtr 句柄,Android.Runtime.JniHandleOwnership transfer) [0x00054] in:0 在Java.Interop.TypeManager.CreateInstance(System.IntPtr 句柄,Android.Runtime.JniHandleOwnership 转移,System.Type targetType)[0x00111] 在:0 05-02 14:36:57.980I/mono-stdout(16628):在 Java.Interop.TypeManager.CreateInstance(System.IntPtr 句柄,Android.Runtime.JniHandleOwnership 转移,System.Type targetType) [0x00111] in:0 --- 内部异常结束堆栈跟踪 --- 05-02 14:36:57.982 I/mono-stdout(16628):---结束内部异常堆栈跟踪 --- 在Java.Interop.TypeManager.CreateInstance(System.IntPtr 句柄,Android.Runtime.JniHandleOwnership 转移,System.Type targetType)[0x0017d] 在:0 05-02 14:36:57.984I/mono-stdout(16628):在 Java.Interop.TypeManager.CreateInstance(System.IntPtr 句柄,Android.Runtime.JniHandleOwnership 转移,System.Type targetType) [0x0017d] in:0 在 Java.Lang.Object.GetObject(System.IntPtr 句柄,Android.Runtime.JniHandleOwnership 转移,System.Type 类型) [0x000b9] in :005-02 14:36:57.986 I/单声道标准输出(16628):在Java.Lang.Object.GetObject(System.IntPtr 句柄,Android.Runtime.JniHandleOwnership 转让,System.Type 类型)[0x000b9] 在 :0 在Java.Lang.Object._GetObject[T](System.IntPtr 句柄,Android.Runtime.JniHandleOwnership transfer) [0x00017] in:0 05-02 14:36:57.988I/mono-stdout(16628): 在 Java.Lang.Object._GetObject[T](System.IntPtr 句柄,Android.Runtime.JniHandleOwnership 转移)[0x00017] 在:0

CurrentDomainOnUnhandledException ---> System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.Platform+DefaultRenderer from native handle 0xbeb0861c (key_handle 0xb3a225b). ---> System.MissingMethodException: No constructor found for Xamarin.Forms.Platform.Android.Platform+DefaultRenderer::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership) ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown. 05-02 14:36:57.973 I/mono-stdout(16628): System.Exception: CurrentDomainOnUnhandledException ---> System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.Platform+DefaultRenderer from native handle 0xbeb0861c (key_handle 0xb3a225b). ---> System.MissingMethodException: No constructor found for Xamarin.Forms.Platform.Android.Platform+DefaultRenderer::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership) ---> Java.Interop.JavaLocationException: Exception of type 'Java.Interop.JavaLocationException' was thrown. --- End of inner exception stack trace --- 05-02 14:36:57.975 I/mono-stdout(16628):
--- End of inner exception stack trace --- at Java.Interop.TypeManager.CreateProxy (System.Type type, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00054] in :0 05-02 14:36:57.978 I/mono-stdout(16628): at Java.Interop.TypeManager.CreateProxy (System.Type type, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00054] in :0 at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00111] in :0 05-02 14:36:57.980 I/mono-stdout(16628): at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00111] in :0 --- End of inner exception stack trace --- 05-02 14:36:57.982 I/mono-stdout(16628): --- End of inner exception stack trace --- at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x0017d] in :0 05-02 14:36:57.984 I/mono-stdout(16628): at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x0017d] in :0 at Java.Lang.Object.GetObject (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type type) [0x000b9] in :0 05-02 14:36:57.986 I/mono-stdout(16628): at Java.Lang.Object.GetObject (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type type) [0x000b9] in :0 at Java.Lang.Object._GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00017] in :0 05-02 14:36:57.988 I/mono-stdout(16628): at Java.Lang.Object._GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00017] in :0

在 Java.Lang.Object.GetObject[T](System.IntPtr 句柄,Android.Runtime.JniHandleOwnership transfer) [0x00000] in:0 在Java.Lang.Object.GetObject[T] (System.IntPtr jnienv, System.IntPtr句柄,Android.Runtime.JniHandleOwnership 转移)[0x00006] 中:0 在Android.Views.View.n_DispatchTouchEvent_Landroid_view_MotionEvent_(System.IntPtr jnienv, System.IntPtr native__this, System.IntPtrnative_e) [0x00000] in :0 at(包装器动态方法)System.Object:3943ee27-49d5-404c-b2ef-5f107b52e084(intptr,intptr,intptr) --- 内部异常堆栈跟踪结束

at Java.Lang.Object.GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00000] in :0 at Java.Lang.Object.GetObject[T] (System.IntPtr jnienv, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00006] in :0 at Android.Views.View.n_DispatchTouchEvent_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) [0x00000] in :0 at (wrapper dynamic-method) System.Object:3943ee27-49d5-404c-b2ef-5f107b52e084 (intptr,intptr,intptr) --- End of inner exception stack trace

推荐答案

我在这个问题上做了很多研究工作.我知道当系统调用 GC 时,它会收集所有对象,如托管、非托管、对等对象.对等对象是 PCL 中使用的本机对象.当这些对象为空时,系统不知道需要重新创建这些对象.所以应该告诉系统您需要创建对象.

只需向所有自定义渲染器添加构造函数即可完成.public CustomEntryImageRenderer(IntPtr handle, JniHandleOwnership transfer) { }

It can be done by just adding constructor to all custom renderers. public CustomEntryImageRenderer(IntPtr handle, JniHandleOwnership transfer) { }

我将所有控件更改为自定义渲染器,并为所有渲染器添加了此构造函数.

I changed all my controls to custom renderers and added this constructor for all renderers.

如果您使用任何 rg 插件弹出窗口,请将动画设置为 false.

If you are using any rg plugins popup, set animation to false.

4.将以下覆盖方法添加到您的自定义渲染器列表视图中.

4.Add below override method to your custom renderer listview.

    protected override void Dispose(bool disposing)
    {

        Xamarin.Forms.Device.BeginInvokeOnMainThread(base.Dispose);

    }

这篇关于Xamarin.Forms.Platform.Android.Platform+DefaultRenderer 来自本机句柄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-24 18:47:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1068536.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:句柄   本机   Forms   Xamarin   Platform

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!