From a4113d73f7ea5b72556a8d60053e4cef2bf617ae Mon Sep 17 00:00:00 2001 From: Simon Rozsival Date: Fri, 29 May 2026 12:35:47 +0200 Subject: [PATCH] Revert CheckBox to DI handler registration as workaround for #35665 The `[ElementHandler]` attribute on CheckBox causes handler resolution to fail on .NET 11 preview Android Release builds (TypeLoadException on CoreCLR, HandlerNotFoundException on Mono/NativeAOT). As a temporary workaround, remove the attribute from CheckBox (the only type using it) and register the handler via the regular DI path. The ElementHandler attribute mechanism will be reworked in #29952. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/Controls/src/Core/CheckBox/CheckBox.cs | 1 - src/Controls/src/Core/Hosting/AppHostBuilderExtensions.cs | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controls/src/Core/CheckBox/CheckBox.cs b/src/Controls/src/Core/CheckBox/CheckBox.cs index 03423defc58c..08c55c0d03f2 100644 --- a/src/Controls/src/Core/CheckBox/CheckBox.cs +++ b/src/Controls/src/Core/CheckBox/CheckBox.cs @@ -16,7 +16,6 @@ namespace Microsoft.Maui.Controls /// Use the property to determine or set the state. /// [DebuggerDisplay("{GetDebuggerDisplay(), nq}")] - [ElementHandler] public partial class CheckBox : View, IElementConfiguration, IBorderElement, IColorElement, ICheckBox, ICommandElement { readonly Lazy> _platformConfigurationRegistry; diff --git a/src/Controls/src/Core/Hosting/AppHostBuilderExtensions.cs b/src/Controls/src/Core/Hosting/AppHostBuilderExtensions.cs index 545ce838cabc..d9377ff10a38 100644 --- a/src/Controls/src/Core/Hosting/AppHostBuilderExtensions.cs +++ b/src/Controls/src/Core/Hosting/AppHostBuilderExtensions.cs @@ -121,6 +121,7 @@ internal static IMauiHandlersCollection AddControlsHandlers(this IMauiHandlersCo handlersCollection.AddHandler(); handlersCollection.AddHandler(); handlersCollection.AddHandler(); + handlersCollection.AddHandler(); handlersCollection.AddHandler(); handlersCollection.AddHandler(); handlersCollection.AddHandler();