.NET Core:多樣的宿主

M守護神發表於2018-12-18
   .NET Core 可以以以下方式作為宿主執行:
  1. IIS
  2. 控制檯
  3. Windows服務
  執行啟動程式碼:
        public static void Main(string[] args)
        {
            try
            {
                LogCenter.Info(“系統啟動”);
                LoadConfig();
                bool isService = !(Debugger.IsAttached ||  args.Contains(“–console”));
                if (isService)
                {
                    CreateWebHostBuilder(args).Build().RunAsService();
                }
                else
                {
                    CreateWebHostBuilder(args).Build().Run();
                }
            }
            catch (Exception ex)
            {
                LogCenter.Error(ex);
            }
        }

相關文章