File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed
Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -942,7 +942,7 @@ If you have other applications such as ASP.NET in the entire project and want to
942942// Package Import: Microsoft.Extensions.Hosting
943943var builder = Host .CreateApplicationBuilder (); // don't pass args.
944944
945- using var host = builder .Build (); // using
945+ using var host = builder .Build (); // use using for host lifetime
946946ConsoleApp .ServiceProvider = host .Services ; // use host ServiceProvider
947947
948948ConsoleApp .Run (args , ([FromServices ] ILogger <Program > logger ) => logger .LogInformation (" Hello World!" ));
@@ -986,7 +986,7 @@ v4 -> v5 Migration Guide
986986v4 was running on top of ` Microsoft.Extensions.Hosting ` , so build a Host in the same way and set up a ServiceProvider.
987987
988988``` csharp
989- using var host = Host .CreateDefaultBuilder ().Build ();
989+ using var host = Host .CreateDefaultBuilder ().Build (); // use using for host lifetime
990990ConsoleApp .ServiceProvider = host .ServiceProvider ;
991991```
992992
You can’t perform that action at this time.
0 commit comments