Open kklose23 opened 6 months ago
Verified this issue with Visual Studio 17.10.0 preview2 (8.0.14). Can repro on android platform with sample project.
Recently updated to Visual Studio 17.10.0 preview2 - Maui 8.0.7. Everything works fine with IOS (building on windows VS) However for Android, as soon as the flyout menu is enabled on a page, it crashes with the same error
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.Collections.Generic.KeyNotFoundException: The given key 'Microsoft.Maui.Controls.SetterSpecificity' was not present in the dictionary. [mono-rt] at System.Collections.Generic.SortedList
2[[Microsoft.Maui.Controls.SetterSpecificity, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Controls.BindingBase, Microsoft.Maui.Controls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].get_Item(SetterSpecificity key) [mono-rt] at Microsoft.Maui.Controls.BindableObject.RemoveBinding(BindableProperty property, BindablePropertyContext context, SetterSpecificity specificity) in D:\a\_work\1\s\src\Controls\src\Core\BindableObject.cs:line 715 [mono-rt] at Microsoft.Maui.Controls.BindableObject.RemoveBinding(BindableProperty property, SetterSpecificity specificity) in D:\a\_work\1\s\src\Controls\src\Core\BindableObject.cs:line 279 [mono-rt] at Microsoft.Maui.Controls.Setter.UnApply(BindableObject target, SetterSpecificity specificity) in D:\a\_work\1\s\src\Controls\src\Core\Setter.cs:line 98 [mono-rt] at Microsoft.Maui.Controls.Style.UnApplyCore(BindableObject bindable, Style basedOn) in D:\a\_work\1\s\src\Controls\src\Core\Style.cs:line 191 [mono-rt] at Microsoft.Maui.Controls.Style.Microsoft.Maui.Controls.IStyle.UnApply(BindableObject bindable) in D:\a\_work\1\s\src\Controls\src\Core\Style.cs:line 115 [mono-rt] at Microsoft.Maui.Controls.MergedStyle.SetStyle(IStyle implicitStyle, IList
1 classStyles, IStyle style) in D:\a_work\1\s\src\Controls\src\Core\MergedStyle.cs:line 193 [mono-rt] at Microsoft.Maui.Controls.MergedStyle.set_ClassStyles(IList1 value) in D:\a\_work\1\s\src\Controls\src\Core\MergedStyle.cs:line 87 [mono-rt] at Microsoft.Maui.Controls.MergedStyle.OnClassStyleChanged() in D:\a\_work\1\s\src\Controls\src\Core\MergedStyle.cs:line 126 [mono-rt] at Microsoft.Maui.Controls.MergedStyle.<set_StyleClass>b__13_0(BindableObject bindable, Object oldvalue, Object newvalue) in D:\a\_work\1\s\src\Controls\src\Core\MergedStyle.cs:line 70 [mono-rt] at Microsoft.Maui.Controls.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, SetterSpecificity specificity, Boolean silent) in D:\a\_work\1\s\src\Controls\src\Core\BindableObject.cs:line 643 [mono-rt] at Microsoft.Maui.Controls.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes, SetterSpecificity specificity) in D:\a\_work\1\s\src\Controls\src\Core\BindableObject.cs:line 569 [mono-rt] at Microsoft.Maui.Controls.Element.OnResourceChanged(BindableProperty property, Object value, SetterSpecificity specificity) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 815 [mono-rt] at Microsoft.Maui.Controls.Element.OnSetDynamicResource(BindableProperty property, String key, SetterSpecificity specificity) in D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs:line 688 [mono-rt] at Microsoft.Maui.Controls.MergedStyle.set_StyleClass(IList
1 value) in D:\a_work\1\s\src\Controls\src\Core\MergedStyle.cs:line 72 [mono-rt] at Microsoft.Maui.Controls.NavigableElement.set_class(IList1 value) in D:\a\_work\1\s\src\Controls\src\Core\Shell\NavigableElement.cs:line 60 [mono-rt] at Microsoft.Maui.Controls.NavigableElement.set_StyleClass(IList
1 value) in D:\a_work\1\s\src\Controls\src\Core\Shell\NavigableElement.cs:line 50 [mono-rt] at Microsoft.Maui.Controls.BaseShellItem.UpdateFlyoutItemStyles(Grid flyoutItemCell, IStyleSelectable source) in D:\a_work\1\s\src\Controls\src\Core\Shell\BaseShellItem.cs:line 320 [mono-rt] at Microsoft.Maui.Controls.BaseShellItem.<>cDisplayClass81_1.b1(Object sender, EventArgs _) in D:\a_work\1\s\src\Controls\src\Core\Shell\BaseShellItem.cs:line 518 [mono-rt] at Microsoft.Maui.Controls.BindableObject.OnBindingContextChanged() in D:\a_work\1\s\src\Controls\src\Core\BindableObject.cs:line 378 [mono-rt] at Microsoft.Maui.Controls.Element.OnBindingContextChanged() in D:\a_work\1\s\src\Controls\src\Core\Element\Element.cs:line 517 [mono-rt] at Microsoft.Maui.Controls.VisualElement.OnBindingContextChanged() in D:\a_work\1\s\src\Controls\src\Core\VisualElement\VisualElement.cs:line 1231 [mono-rt] at Microsoft.Maui.Controls.View.OnBindingContextChanged() in D:\a_work\1\s\src\Controls\src\Core\View\View.cs:line 255 [mono-rt] at Microsoft.Maui.Controls.Grid.OnBindingContextChanged() in D:\a_work\1\s\src\Controls\src\Core\Layout\Grid.cs:line 353 [mono-rt] at Microsoft.Maui.Controls.BindableObject.BindingContextPropertyChanged(BindableObject bindable, Object oldvalue, Object newvalue) in D:\a_work\1\s\src\Controls\src\Core\BindableObject.cs:line 684 [mono-rt] at Microsoft.Maui.Controls.BindableObject.SetValueActual(BindableProperty property, BindablePropertyContext context, Object value, Boolean currentlyApplying, SetValueFlags attributes, SetterSpecificity specificity, Boolean silent) in D:\a_work\1\s\src\Controls\src\Core\BindableObject.cs:line 643 [mono-rt] at Microsoft.Maui.Controls.BindableObject.SetValueCore(BindableProperty property, Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes, SetterSpecificity specificity) in D:\a_work\1\s\src\Controls\src\Core\BindableObject.cs:line 569 [mono-rt] at Microsoft.Maui.Controls.BindableObject.SetValue(BindableProperty property, Object value) in D:\a_work\1\s\src\Controls\src\Core\BindableObject.cs:line 474 [mono-rt] at Microsoft.Maui.Controls.BindableObject.set_BindingContext(Object value) in D:\a_work\1\s\src\Controls\src\Core\BindableObject.cs:line 54 [mono-rt] at Microsoft.Maui.Controls.Platform.Compatibility.ShellFlyoutRecyclerAdapter.ElementViewHolder.set_Element(Element value) in D:\a_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Shell\Android\ShellFlyoutRecyclerAdapter.cs:line 282 [mono-rt] at Microsoft.Maui.Controls.Platform.Compatibility.ShellFlyoutRecyclerAdapter.OnBindViewHolder(ViewHolder holder, Int32 position) in D:\a_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Shell\Android\ShellFlyoutRecyclerAdapter.cs:line 110 [mono-rt] at AndroidX.RecyclerView.Widget.RecyclerView.Adapter.n_OnBindViewHolder_Landroidx_recyclerview_widget_RecyclerView_ViewHolder_I(IntPtr jnienv, IntPtr nativethis, IntPtr native_holder, Int32 position) in C:\a_work\1\s\generated\androidx.recyclerview.recyclerview\obj\Release et6.0-android\generated\src\AndroidX.RecyclerView.Widget.RecyclerView.cs:line 581 [mono-rt] at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLI_V(_JniMarshal_PPLI_V callback, IntPtr jnienv, IntPtr klazz, IntPtr p0, Int32 p1) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 180 [mono-rt] at Java.Interop.JniEnvironment.InstanceMethods.CallNonvirtualVoidMethod(JniObjectReference instance, JniObjectReference type, JniMethodInfo method, JniArgumentValue args) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/obj/Release/net7.0/JniEnvironment.g.cs:line 20825 [mono-rt] at Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeVirtualVoidMethod(String encodedMember, IJavaPeerable self, JniArgumentValue parameters) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:line 75 [mono-rt] at AndroidX.CoordinatorLayout.Widget.CoordinatorLayout.OnLayout(Boolean changed, Int32 l, Int32 t, Int32 r, Int32 b) in C:\a_work\1\s\generated\androidx.coordinatorlayout.coordinatorlayout\obj\Release et6.0-android\generated\src\AndroidX.CoordinatorLayout.Widget.CoordinatorLayout.cs:line 2704 [mono-rt] at Microsoft.Maui.Controls.Platform.Compatibility.ShellFlyoutLayout.OnLayout(Boolean changed, Int32 left, Int32 top, Int32 right, Int32 bottom) in D:\a_work\1\s\src\Controls\src\Core\Compatibility\Handlers\Shell\Android\ShellFlyoutLayout.cs:line 34 [mono-rt] at AndroidX.CoordinatorLayout.Widget.CoordinatorLayout.n_OnLayout_ZIIII(IntPtr jnienv, IntPtr native this, Boolean changed, Int32 l, Int32 t, Int32 r, Int32 b) in C:\a_work\1\s\generated\androidx.coordinatorlayout.coordinatorlayout\obj\Release et6.0-android\generated\src\AndroidX.CoordinatorLayout.Widget.CoordinatorLayout.cs:line 2688 [mono-rt] at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPZIIII_V(_JniMarshal_PPZIIII_V callback, IntPtr jnienv, IntPtr klazz, Boolean p0, Int32 p1, Int32 p2, Int32 p3, Int32 p4) in /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:line 444
It turns out the issue came from styles.
i had this,
<Style
Class="FlyoutItemLayoutStyle" TargetType="Layout" ApplyToDerivedTypes="True">
i changed the class to "MenuItemLayoutStyle" and i no longer have the error.
<Style
Class="MenuItemLayoutStyle" TargetType="Layout" ApplyToDerivedTypes="True">
any news on this, i have same problem trying to bind FlyoutItem.IsVisible in my AppShellViewModel throw this exception
I have the same problem. The MenuItemLayoutStyle worked but now it appears in another place.
Still an issue on nightly. Only option seems to be to remove the styles as reported.
Waiting for a fix for this here too
Same Problem here, Waiting for Fix.
I got the same issue but I have no idea what causes it
Running Visual Studio 2022 17.10.3 and can reproduce this. Workaround is to disable style FlyoutItemLayoutStyle as described above.
Using shell with styles in a sub project, not using FlyoutItemLayoutStyle
or MenuItemLayoutStyle
This is preventing moving to .Net 8 from .Net 7, this will mean being unable release to Google Play which requires all apps to meet target API level 34 requirements before 31 Aug 2024.
Description
See repro steps and log output
Steps to Reproduce
FlyoutItemLabelStyle
class style with AppThemeBinding TextColor setIsVisible
for aShellContent
itemLink to public reproduction project repository
https://github.com/kklose23/shell-visibility-issue
Version with bug
8.0.3
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
No response
Did you find any workaround?
No
Relevant log output