title: How to inject an IServiceScope into a class in .NET Core
body: <p>I have a problem with injecting <code>Microsoft.Extensions.DependencyInjection.IServiceScope</code> into my class.</p>
  <p>My service implementation:</p>
  <pre><code>public class AccountService : IAccountService
  {
      private readonly IConfiguration _configuration;
      private readonly IServiceScope _services;
  
      public AccountService(
          IConfiguration configuration,
          IServiceScope services) // &lt;-- I can't inject this
      {
          _configuration = configuration;
          _services = services;
      }
      
      public async Task CreateAccount(ExternalAccount externalAccount)
      {
          (some code...)
      }
  }
  </code></pre>
  <p>In startup.cs:</p>
  <pre><code>services.AddTransient&lt;IAccountService, AccountService&gt;();
  </code></pre>
  <p>The problem is that project crashes after above line with following error:</p>
  <blockquote>
  <p>Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: IDS.Quickstart.Account.IAccountService Lifetime: Transient ImplementationType: IDS.Quickstart.Account.AccountService': Unable to resolve service for type 'Microsoft.Extensions.DependencyInjection.IServiceScope' while attempting to activate 'IDS.Quickstart.Account.AccountService'.)
  ---&gt; System.InvalidOperationException: Error while validating the service descriptor 'ServiceType: IDS.Quickstart.Account.IAccountService Lifetime: Transient ImplementationType: IDS.Quickstart.Account.AccountService': Unable to resolve service for type 'Microsoft.Extensions.DependencyInjection.IServiceScope' while attempting to activate 'IDS.Quickstart.Account.AccountService'.</p>
  </blockquote>
  <p>What is the reason my code refuses to work?</p>