I have a very strange problem in my Blazor project. I am using Dependency Inject to user my "CompanyService" service. Here is how I am registering my service
// Servies Injection
services.AddSingleton<UserService, UserService>();
services.AddSingleton<CompanyService, CompanyService>();
And I am injecting that service in my razor component as
@inject CompanyService CompanyService
@inject NavigationManager NavigationManager
I need to pass these services to my ViewModel and I am doing like this (CompanesList is my Razor component name so it is constructor)
public CompaniesList()
{
Context = new CompaniesListVm(NavigationManager, CompanyService);
}
When I debug this code, I always get services as null (both NavigationManager, CompanyService). Here is my file position in my project
Can anyone please help me on this?
P.S I am also using MatBlazor for my UI.
Thank you
Regards J
CompaniesListVm
instead IMO. avoidnew
as possible – agua from mars