I am creating a .Net 5 Blazor WASM non-hosted app. In this configuration there is only one project -- The client. We are told to register our services in Program.cs with this configuration which I have done like this builder.Services.AddScoped<IMyService, MyService>(); In _Imports.razor I also added @using MyApp.Services. In my component I have added @inject Services.MyService MyService and on the page component I have <MyListComponent /> but I still get the following error when browsing to that page:
Program.cs
builder.Services.AddScoped<IMyService, MyService>();
_Imports.razor
@using MyApp.Services
@inject Services.MyService MyService
<MyListComponent />
Unhandled exception rendering component: Cannot provide a value for property 'MyService' on type 'MyApp.Shared.MyList'. There is no registered service of type 'MyApp.Services.MyService'.
You are injecting by interface.
@inject IMyService MyService
2.1m questions
2.1m answers
60 comments
56.8k users