Blazored / Modal

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

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

Closed schuchuva closed 4 months ago

schuchuva commented 7 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 7 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 5 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 4 months ago

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