Blazored / Modal

A powerful and customizable modal implementation for Blazor applications.
https://blazored.github.io/Modal/
MIT License
782 stars 185 forks source link

Not working for Blazor 8 app in InteractiveWebAssembly mode [Bug] #542

Closed schuchuva closed 8 months ago

schuchuva commented 11 months ago

Not working for Blazor 8 app in InteractiveWebAssembly mode. Created brand new Blazor project with global InteractiveWebAssembly mode, added Blazored.Modal logic according to docs and got runtime error: Unhandled exception rendering component: Cannot provide a value for property 'ModalService' on type 'Blazored.Modal.CascadingBlazoredModal'. There is no registered service of type 'Blazored.Modal.Services.IModalService'. System.InvalidOperationException: Cannot provide a value for property 'ModalService' on type 'Blazored.Modal.CascadingBlazoredModal'. There is no registered service of type 'Blazored.Modal.Services.IModalService'.

fdonnet commented 11 months ago

Maybe you need to declare the service in your .Client project too. If you are using hosted WASM or AutoMode ? I was using this cool compo in a .net 7 pure wasm and it was working, not tested with 8.0 but I will... the last release was one year back... so maybe it is not compatible with all the new render modes.

digitalchrisg commented 9 months ago

.Net8 Add to the Program.cs in your .Site.Client project should do it. builder.Services.AddBlazoredModal();

Then add the <CascadingBlazoredModal> wrapping the router </CascadingBlazoredModal> and that should do it.

chrissainty commented 8 months ago

@digitalchrisg is correct. If you follow those instructions all should be good. 👍