Description
Description
When maui blazor renders a component that injects the PersistentComponentState, it fails.
This documentation shows how to use persisted state in a component.
https://docs.microsoft.com/en-us/aspnet/core/blazor/components/prerendering-and-integration?view=aspnetcore-6.0&pivots=server#persist-prerendered-state
When a component that injects PersistentComponentState is placed into a blazor server or wasm library, it works, as the server library adds it here:
And the wasm adds it in the builder here:
However, this doesn't appear to be added in Maui anywhere, and due to this, when maui blazor includes a component that injects the PersistentComponentState, it will cause an error.
Manually adding the registrations during maui building resolves this, as per workaround.
Steps to Reproduce
- Clone the repro
- Try run MauiApp2. First page will show yellow error bar
- Uncomment lines 23/24 of MauiProgram.cs
- Run it again, and it will now work
Link to public reproduction project repository
https://github.com/mstancombe/MauiBlazorPersistantStateIssueRepro
Version with bug
6.0.400
Last version that worked well
Unknown/Other
Affected platforms
Android, Windows
Affected platform versions
Windows 11
Did you find any workaround?
Using the same registration as the WASM builder does in MauiProgram resolves this:
Relevant log output
No response