-
startup中创建对象保存ApplicationServices
-
在startup中的Configure方法中记录下 app.ApplicationServices
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
Startup.applicationService = app.ApplicationServices;
}
- 获取对象
var machineService= Startup.applicationService.GetService<TestService>();
标签:容器,Configure,app,startup,实例,ApplicationServices,net,applicationService
From: https://www.cnblogs.com/ives/p/17477426.html