title: how to access a singleton service in program.cs which was defined in startup.cs
body: <p>I have defined a singleton service within my startup.cs</p>
  <pre><code>ConfigureServices(){
     ...
     services.AddSingleton&lt;IBenutzerLizenzDaten, BenutzerLizenzDaten&gt;();
     ...
  }
  </code></pre>
  <p>Now I want to access the service in my program.cs. How can I manage this?</p>
  <p>Like:</p>
  <pre><code>public static void Main(string[] args){
     ...
     var host = CreateHostBuilder(args).Build();
  
     var benutzerLizenzDaten = host.Services.GetRequiredService&lt;BenutzerLizenzDaten&gt;(); // &lt;--  Exception occurred, no service registered.
     benutzerLizenzDaten.Init();
  
     host.Run();
  </code></pre>
  <p>Thanks!</p>