Blazored / Toast

A JavaScript free toast library for Blazor and Razor Component applications
https://blazored.github.io/Toast/
MIT License
654 stars 90 forks source link

[Bug] no registered service of type 'Blazored.Toast.Services.IToastService' #261

Closed JohnMarsing closed 1 month ago

JohnMarsing commented 1 month ago

Describe the bug I created a Blazor 8 Hosted WASM Global Interactive app GitHub and am getting this error

InvalidOperationException: Cannot provide a value for property 'ToastService' on type 'Blazored.Toast.BlazoredToasts'. There is no registered service of type 'Blazored.Toast.Services.IToastService'.

I followed the instructions on two separate solution but not luck

I have no problem getting toast to work with a Blazor 8 Standalone Web App, but not for a Hosted App. It's probably something simple I'm missing, but searched to no avail. I've used Blazored.Toast many times in the base but it was for Blazor Server (ver 7)

To Reproduce Steps to reproduce the behavior:

  1. Clone GitHub and run it

Expected behavior To see Toast

Screenshots If applicable, add screenshots to help explain your problem.

Hosting Model (is this issue happening with a certain hosting model?):

JohnMarsing commented 1 month ago

Fixed it @kdcllc showed me the solution I added builder.Services.AddBlazoredToast(); to server Program.cs

JohnMarsing commented 1 month ago

close, done