title: Asp.Net Core No service for type has been registered
body: <p>I have the following two classes</p>
  
  <pre><code>public class RepositoryConnection : IRepositoryConnection{
  
      public RepositoryConnection(IConfiguration configuration, ILogger&lt;RepositoryConnection&gt; logger){
      //STUFF
      }
  
  }
  
  public class AuthenticationTokenFactory : IAuthenticationTokenFactory {
  
     public AuthenticationTokenFactory(ILogger&lt;AuthenticationTokenFactory&gt; logger) {
      //STUFF 
      }
  }
  </code></pre>
  
  <p>Here is my Startup.cs</p>
  
  <pre><code>public class Startup {
  
      public Startup(IConfiguration configuration) {
          Configuration = configuration;
      }
      public void ConfigureServices(IServiceCollection services) {
          services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
          services.AddSingleton&lt;IAuthenticationTokenFactory, AuthenticationTokenFactory&gt;();
          services.AddSingleton&lt;IRepositoryConnection,RepositoryConnection&gt;();
     }
  }
  </code></pre>
  
  <p>I can successfully inject <code>IAuthenticationTokenFactory</code> to controllers but when i try to inject <code>IRepositoryConnection</code> i get the following error→</p>
  
  <blockquote>
    <p>InvalidOperationException: No service for type　&#x27;TrainingCommerce.Accessors.RepositoryConnection&#x27; has been　registered.</p>
  </blockquote>
  
  <hr>
  
  <p>Thanks to comments i immediately noticed my wrongful ways.
  I was trying to access at another line</p>
  
  <pre><code>var debug = ControllerContext.HttpContext.RequestServices.GetRequiredService&lt;RepositoryConnection&gt;();
  </code></pre>