Microsoft.Extensions.Hosting 8.0.0

About

Contains the .NET Generic Host HostBuilder which layers on the Microsoft.Extensions.Hosting.Abstractions package.

Key Features

  • Contains the .NET Generic Host HostBuilder.

How to Use

For a console app project:

    using (IHost host = new HostBuilder().Build())
    {
        var lifetime = host.Services.GetRequiredService<IHostApplicationLifetime>();
    
        lifetime.ApplicationStarted.Register(() =>
        {
            Console.WriteLine("Started");
        });
        lifetime.ApplicationStopping.Register(() =>
        {
            Console.WriteLine("Stopping firing");
            Console.WriteLine("Stopping end");
        });
        lifetime.ApplicationStopped.Register(() =>
        {
            Console.WriteLine("Stopped firing");
            Console.WriteLine("Stopped end");
        });
    
        host.Start();
    
        // Listens for Ctrl+C.
        host.WaitForShutdown();
    }

Main Types

The main types provided by this library are:

  • Microsoft.Extensions.Host.
  • Microsoft.Extensions.Hosting.HostApplicationBuilder
  • Microsoft.Extensions.Hosting.HostBuilder
  • Microsoft.Extensions.Hosting.IHostedService
  • Microsoft.Extensions.Hosting.IHostedLifecycleService

Additional Documentation

  • Microsoft.Extensions.Configuration
  • Microsoft.Extensions.DependencyInjection
  • Microsoft.Extensions.Hosting.Abstractions
  • Microsoft.Extensions.Logging
  • Microsoft.Extensions.Options

Feedback & Contributing

Microsoft.Extensions.Hosting is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.

Showing the top 20 packages that depend on Microsoft.Extensions.Hosting.

Packages Downloads
Microsoft.AspNetCore.Mvc.Testing
Support for writing functional tests for MVC applications. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/3eeb12e106b9e913c3a4dec1a7d16da7b74149eb
617
Microsoft.AspNetCore.Mvc.Testing
Support for writing functional tests for MVC applications. This package was built from the source code at https://github.com/dotnet/aspnetcore/tree/3f1acb59718cadf111a0a796681e3d3509bb3381
284
Quantum.Framework.Core.StandardLib
Package Description
51
Quantum.Framework.Core.StandardLib
Package Description
52
Quantum.Framework.Core.StandardLib
Package Description
53
Quantum.Framework.Core.StandardLib
Package Description
54
Quantum.Framework.Core.StandardLib
Package Description
55
Quantum.Framework.Core.StandardLib
Package Description
57
Quantum.Framework.Core.StandardLib
Package Description
62
Quantum.Framework.Core.StandardLib
Package Description
64
Quantum.Framework.Core.StandardLib
Package Description
74
Quantum.Framework.Core.StandardLib
Package Description
77
Quantum.Framework.Core.StandardLib
Package Description
114
Quantum.Framework.Core.StandardLib
Package Description
153
Quantum.Framework.Core.StandardLib
Package Description
159
Quantum.Framework.Core.StandardLib
Package Description
167
Xunit.DependencyInjection
Use Microsoft.Extensions.DependencyInjection to inject xunit testclass. If you want write Microsoft.Extensions.Logging to ITestOutputHelper, please install Xunit.DependencyInjection.Logging Release notes: 7.0: Add fixture injection and refactor DependencyInjectionTestFramework, you don't have to declare the [assembly: TestFrameworkAttribute] on normal case.
210

https://go.microsoft.com/fwlink/?LinkID=799421

.NET Framework 4.6.2

.NET Standard 2.0

.NET 8.0

.NET Standard 2.1

.NET 7.0

.NET 6.0

Version Downloads Last updated
9.0.0-rc.2.24473.5 1 11/05/2024
9.0.0-rc.1.24431.7 0 09/10/2024
9.0.0-preview.7.24405.7 0 08/13/2024
9.0.0-preview.6.24327.7 0 07/09/2024
9.0.0-preview.5.24306.7 0 06/11/2024
9.0.0-preview.4.24266.19 8 05/22/2024
9.0.0-preview.3.24172.9 6 05/20/2024
9.0.0-preview.2.24128.5 7 05/05/2024
9.0.0-preview.1.24080.9 2 05/09/2024
8.0.1 0 10/08/2024
8.0.0 134 02/04/2024
8.0.0-rc.2.23479.6 2 05/09/2024
8.0.0-rc.1.23419.4 3 05/09/2024
8.0.0-preview.7.23375.6 2 05/28/2024
8.0.0-preview.6.23329.7 15 08/08/2023
8.0.0-preview.5.23280.8 1 05/28/2024
8.0.0-preview.4.23259.5 5 05/09/2024
8.0.0-preview.3.23174.8 2 05/22/2024
8.0.0-preview.2.23128.3 2 05/09/2024
8.0.0-preview.1.23110.8 3 05/09/2024
7.0.1 8 07/13/2023
7.0.0 16 02/02/2023
7.0.0-rc.2.22472.3 3 05/28/2024
7.0.0-rc.1.22426.10 4 05/09/2024
7.0.0-preview.7.22375.6 2 05/28/2024
7.0.0-preview.6.22324.4 3 05/28/2024
7.0.0-preview.5.22301.12 4 05/28/2024
7.0.0-preview.4.22229.4 5 05/09/2024
7.0.0-preview.2.22152.2 3 05/28/2024
7.0.0-preview.1.22076.8 1 05/28/2024
6.0.2-mauipre.1.22102.15 2 05/22/2024
6.0.2-mauipre.1.22054.8 2 05/28/2024
6.0.0-rc.2.21480.5 2 05/28/2024
6.0.0-rc.1.21451.13 2 05/28/2024
6.0.0-preview.5.21301.5 3 05/22/2024
6.0.0-preview.4.21253.7 5 05/11/2022
6.0.0-preview.3.21201.4 0 04/08/2021
6.0.0-preview.2.21154.6 4 05/22/2024
6.0.0-preview.1.21102.12 2 05/28/2024
5.0.0 2 05/28/2024
5.0.0-rc.2.20475.5 4 05/28/2024
5.0.0-rc.1.20451.14 1 05/28/2024
5.0.0-preview.7.20364.11 2 05/28/2024
5.0.0-preview.4.20251.6 4 05/22/2024
5.0.0-preview.3.20215.2 1 05/28/2024
5.0.0-preview.2.20160.3 3 05/22/2024
5.0.0-preview.1.20120.4 6 05/22/2024
3.1.32 8,809 05/12/2023
3.1.31 0 11/08/2022
3.1.30 5,329 11/03/2022
3.1.29 4 05/15/2024
3.1.28 4 05/09/2024
3.1.27 0 07/12/2022
3.1.26 6 05/17/2024
3.1.25 3 05/09/2024
3.1.20 0 10/11/2021
3.1.19 0 09/14/2021
3.1.18 0 08/10/2021
3.1.15 1 11/09/2024
3.1.4 2 05/28/2024
3.1.2 12 06/15/2022
3.1.1 1 05/28/2024
3.1.0-preview3.19553.2 3 05/28/2024
3.1.0-preview2.19525.4 3 05/28/2024
3.1.0-preview1.19506.1 3 05/28/2024
3.0.0-rc1.19456.10 3 05/28/2024
3.0.0-preview8.19405.4 2 05/28/2024
3.0.0-preview7.19362.4 1 05/28/2024
3.0.0-preview3.19153.1 5 05/28/2024
3.0.0-preview.18572.1 4 05/28/2024
2.2.0-preview3-35497 1 05/28/2024
2.2.0-preview1-35029 3 05/28/2024
2.1.0 128 06/25/2022
2.1.0-rc1-final 1 05/28/2024
2.1.0-preview2-final 3 05/11/2022
2.1.0-preview1-final 2 05/28/2024