title: .Net Core Dependency Injection in Console App
body: <p>I am trying to use dependency injection in a .NET Core Console App.
  There are a lot of articles about it, but did not find one that fixes my problem.
  I am trying to use services original from an aspnet core web app, thats why i have the WebHost.</p>
  
  <p>My main problem is to create an instance of my own class, all the dependency seems to work, and my console app starts up.</p>
  
  <p>I have this code in my Program class:</p>
  
  <pre><code>static void Main(string[] args)
  {            
      var host = WebHost.CreateDefaultBuilder(args)
          .UseKestrel(options =&gt; options.AddServerHeader = false)
          .UseStartup&lt;Startup&gt;()
          .Build();
  
      var services = new ServiceCollection().AddLogging();            
      var container = new Container();           
      var serviceProvider = container.GetInstance&lt;IServiceProvider&gt;();
  </code></pre>
  
  <p>This code will not compile due to this error:
  'Container' does not contain a definition for 'GetInstance' </p>
  
  <p>How can i create an instance of my custom class App which has this implementation:</p>
  
  <pre><code>public class App
  {
      private readonly IProductService _productService;
  
      public App(IProductService productService)
      {
          _productService = productService;
      }
  }
  </code></pre>