47 lines
1.4 KiB
C#
47 lines
1.4 KiB
C#
namespace MiaoYu.WinFormDemo;
|
|
|
|
internal static class Program
|
|
{
|
|
/// <summary>
|
|
/// The main entry point for the application.
|
|
/// </summary>
|
|
[STAThread]
|
|
static void Main()
|
|
{
|
|
// To customize application configuration such as set high DPI settings or default font,
|
|
// see https://aka.ms/applicationconfiguration.
|
|
ApplicationConfiguration.Initialize();
|
|
|
|
// 设置 aspnetcore 启动端口 和 启动环境
|
|
var args = new string[] { "--urls", "http://*:7070", Environments.Development };
|
|
|
|
try
|
|
{
|
|
HzyApplication.Run<WinFormDemoStartup>(args, options =>
|
|
{
|
|
options.WebApplicationBuilderAction = webApplicationBuilder =>
|
|
{
|
|
webApplicationBuilder.Services.AddTransient<Form1>();
|
|
};
|
|
|
|
options.WebApplicationAction = webApplication =>
|
|
{
|
|
// 从 ioc 容器中获取窗体
|
|
var form1 = webApplication.Services.GetService<Form1>();
|
|
// 运行主窗体
|
|
Application.Run(form1);
|
|
};
|
|
|
|
});
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogUtil.Log.Fatal(ex, "主机意外终止...");
|
|
throw;
|
|
}
|
|
finally
|
|
{
|
|
Log.CloseAndFlush();
|
|
}
|
|
}
|
|
} |