Program.cs 884 B

123456789101112131415161718192021222324
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. using Microsoft.AspNetCore.Hosting;
  4. using Microsoft.Extensions.DependencyInjection;
  5. using Microsoft.Extensions.Hosting;
  6. namespace IStartupInjectionAssemblyName;
  7. public class Program
  8. {
  9. public static void Main(string[] args)
  10. {
  11. var webHost = CreateWebHostBuilder(args).Build();
  12. var applicationName = webHost.Services.GetRequiredService<IHostEnvironment>().ApplicationName;
  13. Console.WriteLine(applicationName);
  14. }
  15. // Do not change the signature of this method. It's used for tests.
  16. private static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
  17. new WebHostBuilder()
  18. .SuppressStatusMessages(true)
  19. .ConfigureServices(services => services.AddSingleton<IStartup, Startup>());
  20. }