step 1:创建 WinForm(.Net Core)项目
step 2:
// 安装 DI 组件
Install-Package Microsoft.Extensions.DependencyInjection
// 安装日志输出组件
Install-Package Microsoft.Extensions.Logging.Console
step 3:
path:\Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Extensions.DependencyInjection;
namespace WindowsFormsApp10
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
var serviceProvider = new ServiceCollection()
.AddLogging()
.BuildServiceProvider();
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}