using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Serilog; using Serilog.Events; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; using Volo.Abp; namespace WinFormsApp { public class Program { /// /// The main entry point for the application. /// // [STAThread] static async Task Main() { Log.Logger = new LoggerConfiguration() #if DEBUG .MinimumLevel.Debug() #else .MinimumLevel.Information() #endif .MinimumLevel.Override("Microsoft", LogEventLevel.Information) .Enrich.FromLogContext() .WriteTo.Async(c => c.File("Logs/logs.txt")) .CreateLogger(); try { Log.Information("Starting web host."); using (var host =Host .CreateDefaultBuilder(null) .UseAutofac() .UseSerilog() .ConfigureServices((hostContext, services) => { services.AddApplication(); }).Build()) { await host.StartAsync(); } using (var application = AbpApplicationFactory.Create()) { application.Initialize(); // Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var mainForm = application.ServiceProvider.GetService(); Application.Run(mainForm); } } catch (Exception ex ) { Log.Fatal(ex, "Host terminated unexpectedly!"); return; } finally { Log.CloseAndFlush(); } } } }