gpt4 book ai didi

c# - 系统.TypeLoadException : 'VTable setup of type AndroidX.AppCompat.View.Menu.MenuItemImpl failed'

转载 作者:行者123 更新时间:2023-12-05 00:04:22 24 4
gpt4 key购买 nike

我正在尝试将 Xamarin Android 应用程序升级到 AndroidX。我经历了迁移过程并且项目构建没有错误,但在运行时我遇到了 IMenu 的问题。我有一个调用 OnCreateOptionsMenu(IMenu menu) 的 Activity ,当它到达 menu.FindItem 时,System.TypeLoadException: 'AndroidX.AppCompat 类型的 VTable 设置。 View.Menu.MenuItemImpl failed' 被抛出。

        public override bool OnCreateOptionsMenu(IMenu menu)
{
MenuInflater.Inflate(Resource.Menu.common_menu, menu);
menu.FindItem(Resource.Id.action_settings).SetVisible(false); // Exception happens here.
return true;
}

堆栈跟踪:

  at System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x0002c] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:951 
at System.Reflection.RuntimeConstructorInfo.DoInvoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00086] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:926
at System.Reflection.RuntimeConstructorInfo.Invoke (System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:960
at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Reflection/ConstructorInfo.cs:22
at Java.Interop.TypeManager.CreateProxy (System.Type type, System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x0001b] in <7d2292394f8c488b97f5bc2a0ac0240d>:0
at Java.Interop.TypeManager.CreateInstance (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type targetType) [0x00111] in <7d2292394f8c488b97f5bc2a0ac0240d>:0
at Java.Lang.Object.GetObject (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer, System.Type type) [0x00023] in <7d2292394f8c488b97f5bc2a0ac0240d>:0
at Java.Lang.Object._GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00017] in <7d2292394f8c488b97f5bc2a0ac0240d>:0
at Java.Lang.Object.GetObject[T] (System.IntPtr handle, Android.Runtime.JniHandleOwnership transfer) [0x00000] in <7d2292394f8c488b97f5bc2a0ac0240d>:0
at AndroidX.AppCompat.View.Menu.MenuBuilder.FindItem (System.Int32 id) [0x00036] in <c5220b8e1f564a28bc774e534daebefd>:0
at NatureMapr.Mobile.Droid.Activities.BaseActivity.OnCreateOptionsMenu (Android.Views.IMenu menu) [0x00013] in C:\Projects\NatureMapr\NatureMapr.Mobile.Droid\Activities\BaseActivity.cs:73
at Android.App.Activity.n_OnCreateOptionsMenu_Landroid_view_Menu_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_menu) [0x0000f] in <7d2292394f8c488b97f5bc2a0ac0240d>:0
at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.8(intptr,intptr,intptr)

非常感谢任何有关我如何追踪问题的帮助。

最佳答案

对于遇到此错误的任何其他人,这看起来像是一个或多个 1.0.0-preview02 Xamarin AndroidX NuGet 包的问题。升级到 1.0.0.2 包已经解决了我的问题。

关于c# - 系统.TypeLoadException : 'VTable setup of type AndroidX.AppCompat.View.Menu.MenuItemImpl failed' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63642667/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com