title: Blazor - Dependency Injection is not working
body: <p>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</p>
  
  <pre><code>// Servies Injection
  services.AddSingleton&lt;UserService, UserService&gt;();
  services.AddSingleton&lt;CompanyService, CompanyService&gt;();
  </code></pre>
  
  <p>And I am injecting that service in my razor component as</p>
  
  <pre><code>@inject CompanyService CompanyService
  @inject NavigationManager NavigationManager
  </code></pre>
  
  <p>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)</p>
  
  <pre><code>public CompaniesList()
  {
      Context = new CompaniesListVm(NavigationManager, CompanyService);
  }
  </code></pre>
  
  <p>When I debug this code, I always get services as null (both NavigationManager, CompanyService). Here is my file position in my project</p>
  
  <p><a href="https://i.stack.imgur.com/sgIG8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sgIG8.png" alt="enter image description here"></a></p>
  
  <p>Can anyone please help me on this?</p>
  
  <p>P.S I am also using MatBlazor for my UI.</p>
  
  <p>Thank you</p>
  
  <p>Regards
  J</p>