BuildServiceProviderWithSelf无用,改用原生方法
This commit is contained in:
parent
495e52c2e6
commit
bfcfa4ee9b
@ -21,9 +21,9 @@ namespace PrivateBox
|
|||||||
services.AddSingleton(appConfig);
|
services.AddSingleton(appConfig);
|
||||||
services.AddSingleton<AppRunTimeSettings>();
|
services.AddSingleton<AppRunTimeSettings>();
|
||||||
AddServices(services,appConfig);
|
AddServices(services,appConfig);
|
||||||
using var providerScope = services.BuildServiceProviderWithSelf().CreateScope();
|
using var providerScope = services.BuildServiceProvider().CreateScope();
|
||||||
var sp = providerScope.ServiceProvider;
|
var sp = providerScope.ServiceProvider;
|
||||||
var logger = sp.GetRequiredService<ILoggerFactory>().CreateLogger("PrivateBoxMain");
|
var logger = sp.GetRequiredService<ILoggerFactory>().CreateLogger("Main");
|
||||||
var mainForm = sp.GetRequiredService<MainForm>();
|
var mainForm = sp.GetRequiredService<MainForm>();
|
||||||
logger.LogInformation($"Application will run main:{mainForm.GetType().FullName}");
|
logger.LogInformation($"Application will run main:{mainForm.GetType().FullName}");
|
||||||
Application.Run(mainForm);
|
Application.Run(mainForm);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user