.NET MAUI 无法绑定到目标方法,因为其签名与委托类型的签名不兼容

问题描述 投票:0回答:1

当我启动应用程序时,它崩溃并出现异常:

Cannot bind to the target method because its signature is not compatible with that of the delegate type
。初始屏幕上出现错误。这是我得到的整个日志:

**System.ArgumentException:** 'Cannot bind to the target method because its signature is not compatible with that of the delegate type.'

**System.ArgumentException:** 'Cannot bind to the target method because its signature is not compatible with that of the delegate type.'

[AppCenterXamarinCrashes] Unhandled Exception from source=AppDomain
[AppCenterXamarinCrashes] System.ArgumentException: Cannot bind to the target method because its signature is not compatible with that of the delegate type.
[AppCenterXamarinCrashes]    at System.Delegate.CreateDelegate(Type type, Type target, String method, Boolean ignoreCase, Boolean throwOnBindFailure)
[AppCenterXamarinCrashes]    at System.Delegate.CreateDelegate(Type type, Type target, String method)
[AppCenterXamarinCrashes]    at Android.Runtime.AndroidTypeManager.RegisterNativeMembers(JniType nativeClass, Type type, ReadOnlySpan`1 methods) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/AndroidRuntime.cs:line 557
[AppCenterXamarinCrashes] --- End of stack trace from previous location ---
[AppCenterXamarinCrashes]    at Java.Interop.JniEnvironment.Object.AllocObject(JniObjectReference type) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/obj/Release/net7.0/JniEnvironment.g.cs:line 20911
[AppCenterXamarinCrashes]    at Java.Interop.JniType.AllocObject() in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniType.cs:line 196
[AppCenterXamarinCrashes]    at Java.Interop.JniPeerMembers.JniInstanceMethods.StartCreateInstance(String constructorSignature, Type declaringType, JniArgumentValue* parameters) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods.cs:line 139
[AppCenterXamarinCrashes]    at AndroidX.AppCompat.Widget.AppCompatTextView..ctor(Context context) in C:\a\_work\1\s\generated\androidx.appcompat.appcompat\obj\Release
et6.0-android\generated\src\AndroidX.AppCompat.Widget.AppCompatTextView.cs:line 51
[AppCenterXamarinCrashes]    at Microsoft.Maui.Platform.MauiTextView..ctor(Context context) in D:\a\_work\1\s\src\Core\src\Platform\Android\MauiTextView.cs:line 9
[AppCenterXamarinCrashes]    at Microsoft.Maui.Handlers.LabelHandler.CreatePlatformView() in D:\a\_work\1\s\src\Core\src\Handlers\Label\LabelHandler.Android.cs:line 10
[AppCenterXamarinCrashes]    at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.ILabel, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[AndroidX.AppCompat.Widget.AppCompatTextView, Xamarin.AndroidX.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].OnCreatePlatformView() in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 72
[AppCenterXamarinCrashes]    at Microsoft.Maui.Handlers.ViewHandler.OnCreatePlatformElement() in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandler.cs:line 184
[AppCenterXamarinCrashes]    at Microsoft.Maui.Handlers.ElementHandler.CreatePlatformElement() in D:\a\_work\1\s\src\Core\src\Handlers\Element\ElementHandler.cs:line 101
[AppCenterXamarinCrashes]    at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view) in D:\a\_work\1\s\src\Core\src\Handlers\Element\ElementHandler.cs:line 50
[AppCenterXamarinCrashes]    at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.ILabel, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[AndroidX.AppCompat.Widget.AppCompatTextView, Xamarin.AndroidX.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IView view) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 53
[AppCenterXamarinCrashes]    at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.ILabel, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[AndroidX.AppCompat.Widget.AppCompatTextView, Xamarin.AndroidX.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 56
[AppCenterXamarinCrashes]    at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 921
[AppCenterXamarinCrashes]    at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 863
[AppCenterXamarinCrashes]    at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) in D:\a\_work\1\s\src\Controls\src\Core\VisualElement\VisualElement.cs:line 2031
[AppCenterXamarinCrashes]    at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 96
[AppCenterXamarinCrashes]    at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 127
[AppCenterXamarinCrashes]    at Microsoft.Maui.Controls.Handlers.Compatibility.FrameRenderer.UpdateContent() in D:\a\_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Android\FrameRenderer.cs:line 354
[AppCenterXamarinCrashes]    at Microsoft.Maui.Controls.Handlers.Compatibility.FrameRenderer.<>c.<.cctor>b__73_6(FrameRenderer h, Frame _) in D:\a\_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Android\FrameRenderer.cs:line 28
[AppCenterXamarinCrashes]    at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0[[Microsoft.Maui.Controls.Frame, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Controls.Handlers.Compatibility.FrameRenderer, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<Add>b__0(IElementHandler h, IElement v) in D:\a\_work\1\s\src\Core\src\PropertyMapper.cs:line 172
[AppCenterXamarinCrashes]    at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView) in D:\a\_work\1\s\src\Core\src\PropertyMapper.cs:line 47
[AppCenterXamarinCrashes]    at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView) in D:\a\_work\1\s\src\Core\src\PropertyMapper.cs:line 82
[AppCenterXamarinCrashes]    at Microsoft.Maui.Controls.Handlers.Compatibility.VisualElementRenderer`1[[Microsoft.Maui.Controls.Frame, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view, IPlatformViewHandler nativeViewHandler, Action`1 onElementChanged, Frame& currentVirtualView, IPropertyMapper& _mapper, IPropertyMapper _defaultMapper, Boolean autoPackage) in D:\a\_work\1\s\src\Controls\src\Core\Compatibility\Handlers\VisualElementRenderer.cs:line 290
[AppCenterXamarinCrashes]    at Microsoft.Maui.Controls.Handlers.Compatibility.ViewHandlerDelegator`1[[Microsoft.Maui.Controls.Frame, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view, Action`1 onElementChanged, Boolean autoPackage) in D:\a\_work\1\s\src\Controls\src\Core\Compatibility\Handlers\ViewHandlerDelegator.cs:line 84
[AppCenterXamarinCrashes]    at Microsoft.Maui.Controls.Handlers.Compatibility.FrameRenderer.Microsoft.Maui.IElementHandler.SetVirtualView(IElement view) in D:\a\_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Android\FrameRenderer.cs:line 405
[AppCenterXamarinCrashes]    at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 921
[AppCenterXamarinCrashes]    at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 863
[AppCenterXamarinCrashes]    at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) in D:\a\_work\1\s\src\Controls\src\Core\VisualElement\VisualElement.cs:line 2031
[AppCenterXamarinCrashes]    at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 96
[AppCenterXamarinCrashes]    at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 127
[AppCenterXamarinCrashes]    at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView view) in D:\a\_work\1\s\src\Core\src\Handlers\Layout\LayoutHandler.Android.cs:line 41
[AppCenterXamarinCrashes]    at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.ILayout, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.LayoutViewGroup, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 56
[AppCenterXamarinCrashes]    at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 921
[AppCenterXamarinCrashes]    at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 863
[AppCenterXamarinCrashes]    at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) in D:\a\_work\1\s\src\Controls\src\Core\VisualElement\VisualElement.cs:line 2031
[AppCenterXamarinCrashes]    at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 96
[AppCenterXamarinCrashes]    at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 127
[AppCenterXamarinCrashes]    at Microsoft.Maui.Handlers.ContentViewHandler.UpdateContent(IContentViewHandler handler) in D:\a\_work\1\s\src\Core\src\Handlers\ContentView\ContentViewHandler.Android.cs:line 42
[AppCenterXamarinCrashes]    at Microsoft.Maui.Handlers.ContentViewHandler.MapContent(IContentViewHandler handler, IContentView page) in D:\a\_work\1\s\src\Core\src\Handlers\ContentView\ContentViewHandler.Android.cs:line 47
[AppCenterXamarinCrashes]    at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IContentViewHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<Add>b__0(IElementHandler h, IElement v) in D:\a\_work\1\s\src\Core\src\PropertyMapper.cs:line 172
[AppCenterXamarinCrashes]    at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView) in D:\a\_work\1\s\src\Core\src\PropertyMapper.cs:line 47
[AppCenterXamarinCrashes]    at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView) in D:\a\_work\1\s\src\Core\src\PropertyMapper.cs:line 82
[AppCenterXamarinCrashes]    at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view) in D:\a\_work\1\s\src\Core\src\Handlers\Element\ElementHandler.cs:line 79
[AppCenterXamarinCrashes]    at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.ContentViewGroup, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IView view) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 53
[AppCenterXamarinCrashes]    at Microsoft.Maui.Handlers.ContentViewHandler.SetVirtualView(IView view) in D:\a\_work\1\s\src\Core\src\Handlers\ContentView\ContentViewHandler.Android.cs:line 26
[AppCenterXamarinCrashes]    at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.ContentViewGroup, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 56
[AppCenterXamarinCrashes]    at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 921
[AppCenterXamarinCrashes]    at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 863
[AppCenterXamarinCrashes]    at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) in D:\a\_work\1\s\src\Controls\src\Core\VisualElement\VisualElement.cs:line 2031
[AppCenterXamarinCrashes]    at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 96
[AppCenterXamarinCrashes]    at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 127
[AppCenterXamarinCrashes]    at Microsoft.Maui.Platform.MauiContextExtensions.ToPlatform(IView view, IMauiContext fragmentMauiContext, Context context, LayoutInflater layoutInflater, FragmentManager childFragmentManager) in D:\a\_work\1\s\src\Core\src\Platform\Android\MauiContextExtensions.cs:line 96
[AppCenterXamarinCrashes]    at Microsoft.Maui.Controls.Platform.Compatibility.ShellFragmentContainer.OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) in D:\a\_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Shell\Android\ShellFragmentContainer.cs:line 26
[AppCenterXamarinCrashes]    at AndroidX.Fragment.App.Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_os_Bundle_(IntPtr jnienv, IntPtr native__this, IntPtr native_inflater, IntPtr native_container, IntPtr native_savedInstanceState) in C:\a\_work\1\s\generated\androidx.fragment.fragment\obj\Release
et6.0-android\generated\src\AndroidX.Fragment.App.Fragment.cs:line 2031
[AppCenterXamarinCrashes]    at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLLL_L(_JniMarshal_PPLLL_L callback, IntPtr jnienv, IntPtr klazz, IntPtr p0, IntPtr p1, IntPtr p2) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 367
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: Cannot bind to the target method because its signature is not compatible with that of the delegate type.
[mono-rt]    at System.Delegate.CreateDelegate(Type type, Type target, String method, Boolean ignoreCase, Boolean throwOnBindFailure)
[mono-rt]    at System.Delegate.CreateDelegate(Type type, Type target, String method)
[mono-rt]    at Android.Runtime.AndroidTypeManager.RegisterNativeMembers(JniType nativeClass, Type type, ReadOnlySpan`1 methods) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/AndroidRuntime.cs:line 557
[mono-rt] --- End of stack trace from previous location ---
[mono-rt]    at Java.Interop.JniEnvironment.Object.AllocObject(JniObjectReference type) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/obj/Release/net7.0/JniEnvironment.g.cs:line 20911
[mono-rt]    at Java.Interop.JniType.AllocObject() in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniType.cs:line 196
[mono-rt]    at Java.Interop.JniPeerMembers.JniInstanceMethods.StartCreateInstance(String constructorSignature, Type declaringType, JniArgumentValue* parameters) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods.cs:line 139
[mono-rt]    at AndroidX.AppCompat.Widget.AppCompatTextView..ctor(Context context) in C:\a\_work\1\s\generated\androidx.appcompat.appcompat\obj\Release
et6.0-android\generated\src\AndroidX.AppCompat.Widget.AppCompatTextView.cs:line 51
[mono-rt]    at Microsoft.Maui.Platform.MauiTextView..ctor(Context context) in D:\a\_work\1\s\src\Core\src\Platform\Android\MauiTextView.cs:line 9
[mono-rt]    at Microsoft.Maui.Handlers.LabelHandler.CreatePlatformView() in D:\a\_work\1\s\src\Core\src\Handlers\Label\LabelHandler.Android.cs:line 10
[mono-rt]    at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.ILabel, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[AndroidX.AppCompat.Widget.AppCompatTextView, Xamarin.AndroidX.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].OnCreatePlatformView() in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 72
[mono-rt]    at Microsoft.Maui.Handlers.ViewHandler.OnCreatePlatformElement() in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandler.cs:line 184
[mono-rt]    at Microsoft.Maui.Handlers.ElementHandler.CreatePlatformElement() in D:\a\_work\1\s\src\Core\src\Handlers\Element\ElementHandler.cs:line 101
[mono-rt]    at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view) in D:\a\_work\1\s\src\Core\src\Handlers\Element\ElementHandler.cs:line 50
[mono-rt]    at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.ILabel, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[AndroidX.AppCompat.Widget.AppCompatTextView, Xamarin.AndroidX.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IView view) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 53
[mono-rt]    at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.ILabel, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[AndroidX.AppCompat.Widget.AppCompatTextView, Xamarin.AndroidX.AppCompat, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 56
[mono-rt]    at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 921
[mono-rt]    at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 863
[mono-rt]    at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) in D:\a\_work\1\s\src\Controls\src\Core\VisualElement\VisualElement.cs:line 2031
[mono-rt]    at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 96
[mono-rt]    at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 127
[mono-rt]    at Microsoft.Maui.Controls.Handlers.Compatibility.FrameRenderer.UpdateContent() in D:\a\_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Android\FrameRenderer.cs:line 354
[mono-rt]    at Microsoft.Maui.Controls.Handlers.Compatibility.FrameRenderer.<>c.<.cctor>b__73_6(FrameRenderer h, Frame _) in D:\a\_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Android\FrameRenderer.cs:line 28
[mono-rt]    at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0[[Microsoft.Maui.Controls.Frame, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Controls.Handlers.Compatibility.FrameRenderer, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<Add>b__0(IElementHandler h, IElement v) in D:\a\_work\1\s\src\Core\src\PropertyMapper.cs:line 172
[mono-rt]    at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView) in D:\a\_work\1\s\src\Core\src\PropertyMapper.cs:line 47
[mono-rt]    at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView) in D:\a\_work\1\s\src\Core\src\PropertyMapper.cs:line 82
[mono-rt]    at Microsoft.Maui.Controls.Handlers.Compatibility.VisualElementRenderer`1[[Microsoft.Maui.Controls.Frame, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view, IPlatformViewHandler nativeViewHandler, Action`1 onElementChanged, Frame& currentVirtualView, IPropertyMapper& _mapper, IPropertyMapper _defaultMapper, Boolean autoPackage) in D:\a\_work\1\s\src\Controls\src\Core\Compatibility\Handlers\VisualElementRenderer.cs:line 290
[mono-rt]    at Microsoft.Maui.Controls.Handlers.Compatibility.ViewHandlerDelegator`1[[Microsoft.Maui.Controls.Frame, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view, Action`1 onElementChanged, Boolean autoPackage) in D:\a\_work\1\s\src\Controls\src\Core\Compatibility\Handlers\ViewHandlerDelegator.cs:line 84
[mono-rt]    at Microsoft.Maui.Controls.Handlers.Compatibility.FrameRenderer.Microsoft.Maui.IElementHandler.SetVirtualView(IElement view) in D:\a\_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Android\FrameRenderer.cs:line 405
[mono-rt]    at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 921
[mono-rt]    at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 863
[mono-rt]    at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) in D:\a\_work\1\s\src\Controls\src\Core\VisualElement\VisualElement.cs:line 2031
[mono-rt]    at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 96
[mono-rt]    at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 127
[mono-rt]    at Microsoft.Maui.Handlers.LayoutHandler.SetVirtualView(IView view) in D:\a\_work\1\s\src\Core\src\Handlers\Layout\LayoutHandler.Android.cs:line 41
[mono-rt]    at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.ILayout, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.LayoutViewGroup, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 56
[mono-rt]    at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 921
[mono-rt]    at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 863
[mono-rt]    at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) in D:\a\_work\1\s\src\Controls\src\Core\VisualElement\VisualElement.cs:line 2031
[mono-rt]    at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 96
[mono-rt]    at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 127
[mono-rt]    at Microsoft.Maui.Handlers.ContentViewHandler.UpdateContent(IContentViewHandler handler) in D:\a\_work\1\s\src\Core\src\Handlers\ContentView\ContentViewHandler.Android.cs:line 42
[mono-rt]    at Microsoft.Maui.Handlers.ContentViewHandler.MapContent(IContentViewHandler handler, IContentView page) in D:\a\_work\1\s\src\Core\src\Handlers\ContentView\ContentViewHandler.Android.cs:line 47
[mono-rt]    at Microsoft.Maui.PropertyMapper`2.<>c__DisplayClass5_0[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IContentViewHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<Add>b__0(IElementHandler h, IElement v) in D:\a\_work\1\s\src\Core\src\PropertyMapper.cs:line 172
[mono-rt]    at Microsoft.Maui.PropertyMapper.UpdatePropertyCore(String key, IElementHandler viewHandler, IElement virtualView) in D:\a\_work\1\s\src\Core\src\PropertyMapper.cs:line 47
[mono-rt]    at Microsoft.Maui.PropertyMapper.UpdateProperties(IElementHandler viewHandler, IElement virtualView) in D:\a\_work\1\s\src\Core\src\PropertyMapper.cs:line 82
[mono-rt]    at Microsoft.Maui.Handlers.ElementHandler.SetVirtualView(IElement view) in D:\a\_work\1\s\src\Core\src\Handlers\Element\ElementHandler.cs:line 79
[mono-rt]    at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.ContentViewGroup, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IView view) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 53
[mono-rt]    at Microsoft.Maui.Handlers.ContentViewHandler.SetVirtualView(IView view) in D:\a\_work\1\s\src\Core\src\Handlers\ContentView\ContentViewHandler.Android.cs:line 26
[mono-rt]    at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IContentView, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.ContentViewGroup, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].SetVirtualView(IElement view) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 56
[mono-rt]    at Microsoft.Maui.Controls.Element.SetHandler(IElementHandler newHandler) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 921
[mono-rt]    at Microsoft.Maui.Controls.Element.set_Handler(IElementHandler value) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 863
[mono-rt]    at Microsoft.Maui.Controls.VisualElement.Microsoft.Maui.IElement.set_Handler(IElementHandler value) in D:\a\_work\1\s\src\Controls\src\Core\VisualElement\VisualElement.cs:line 2031
[mono-rt]    at Microsoft.Maui.Platform.ElementExtensions.ToHandler(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 96
[mono-rt]    at Microsoft.Maui.Platform.ElementExtensions.ToPlatform(IElement view, IMauiContext context) in D:\a\_work\1\s\src\Core\src\Platform\ElementExtensions.cs:line 127
[mono-rt]    at Microsoft.Maui.Platform.MauiContextExtensions.ToPlatform(IView view, IMauiContext fragmentMauiContext, Context context, LayoutInflater layoutInflater, FragmentManager childFragmentManager) in D:\a\_work\1\s\src\Core\src\Platform\Android\MauiContextExtensions.cs:line 96
[mono-rt]    at Microsoft.Maui.Controls.Platform.Compatibility.ShellFragmentContainer.OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) in D:\a\_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Shell\Android\ShellFragmentContainer.cs:line 26
[mono-rt]    at AndroidX.Fragment.App.Fragment.n_OnCreateView_Landroid_view_LayoutInflater_Landroid_view_ViewGroup_Landroid_os_Bundle_(IntPtr jnienv, IntPtr native__this, IntPtr native_inflater, IntPtr native_container, IntPtr native_savedInstanceState) in C:\a\_work\1\s\generated\androidx.fragment.fragment\obj\Release
et6.0-android\generated\src\AndroidX.Fragment.App.Fragment.cs:line 2031
[mono-rt]    at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLLL_L(_JniMarshal_PPLLL_L callback, IntPtr jnienv, IntPtr klazz, IntPtr p0, IntPtr p1, IntPtr p2) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 367

有人遇到同样的问题吗?我不知道在哪里寻找崩溃...

P.S 该应用程序适用于 iOS

c# .net xamarin xamarin.android maui
1个回答
0
投票

嗯,根据你的评论,作为维基答案:

当我启动应用程序时,它崩溃并出现异常:

Cannot bind to the target method because its signature is not compatible with that of the delegate type

将构建从

bundle
更改为
apk
可以暂时避免该问题。

关于

bundle
apk
,你可以看这个案例:apk(.apk)和app bundle(.aab)之间的区别

Google 使用应用程序包为每个用户的设备配置生成和提供优化的 APK,因此他们只下载运行应用程序所需的代码和资源。因此,用户可以获得更小、更优化的下载。

应该是VS在构建bundle时删除了一些代码和资源,导致错误。

© www.soinside.com 2019 - 2024. All rights reserved.