Skip to content

[Bug]: MAUI: Trimmed app crashes when trying to resolve IActivationForViewFetcher #4147

@EmilienDup

Description

@EmilienDup

Describe the bug 🐞

After upgrading from 20.4.1 to 21.0.1, an exception is thrown when trying to resolve the activation strategy for a page.

The exception is

2025-09-23 14:43:05.184906+0200 ReactiveUIActivationIssue[81432:12421034] Unhandled managed exception: Don't know how to detect when ReactiveUIActivationIssue.MainPage is activated/deactivated, you may need to implement IActivationForViewFetcher (System.ArgumentException)
   at ReactiveUI.ViewForMixins.WhenActivated(IActivatableView , Func`1 , IViewFor )
   at ReactiveUI.ViewForMixins.WhenActivated(IActivatableView , Action`1 , IViewFor )
   at ReactiveUI.ViewForMixins.WhenActivated(IActivatableView , Action`1 )
   at ReactiveUIActivationIssue.MainPage..ctor()
   at System.Reflection.ConstructorInvoker.InterpretedInvoke(Object obj, IntPtr* args)
   at System.Reflection.ConstructorInvoker.InvokeDirectByRefWithFewArgs(Span`1 )
   at System.Reflection.ConstructorInvoker.InvokeDirectByRef(Object , Object , Object , Object )
   at System.Reflection.ConstructorInvoker.InvokeImpl(Object , Object , Object , Object )
   at System.Reflection.ConstructorInvoker.Invoke(Span`1 )
   at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider )
   at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(IServiceProvider , Type , Object[] )
   at Microsoft.Maui.Controls.ShellContent.<>c__DisplayClass20_0.<Microsoft.Maui.Controls.IShellContentController.GetOrCreateContent>b__0()
   at Microsoft.Maui.Controls.ElementTemplate.CreateContent()
   at Microsoft.Maui.Controls.Internals.DataTemplateExtensions.CreateContent(DataTemplate self, Object item, BindableObject container)
   at Microsoft.Maui.Controls.ShellContent.Microsoft.Maui.Controls.IShellContentController.GetOrCreateContent()
   at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRootRenderer.LoadRenderers()
   at Microsoft.Maui.Controls.Platform.Compatibility.ShellSectionRootRenderer.ViewDidLoad()
--- End of stack trace from previous location ---
   at ObjCRuntime.Runtime.ThrowException(IntPtr )
   at UIKit.UIApplication.UIApplicationMain(Int32 , String[] , IntPtr , IntPtr )
   at UIKit.UIApplication.Main(String[] , Type , Type )
   at ReactiveUIActivationIssue.Program.Main(String[] args)

It worked well with 20.4.1 but not anymore with 21.0.1.
I haven't found any documentation about a breaking change necessitating a change on the app trimming parameters.

Am I missing something?

Thanks a lot.

Step to reproduce

  1. Deploy the sample project in Release mode
  2. Observe the crash

Reproduction repository

https://github.com/EmilienDup/ReactiveUITrimmedApp

Expected behavior

Expected behavior

Screenshots 🖼️

No response

IDE

No response

Operating system

No response

Version

No response

Device

No response

ReactiveUI Version

21.0.1

Additional information ℹ️

A workaround seems to instruct the trimmer to exclude ReactiveUI assemblies from the trimming process

  <ItemGroup>
      <TrimmerRootAssembly Include="ReactiveUI" />
      <TrimmerRootAssembly Include="ReactiveUI.Maui" />
  </ItemGroup>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions