Partager via


Microsoft.Extensions.Hosting Namespace

Provides classes that allow you to encapsulate an app's resources and lifetime functionality.

Classes

ApplicationMetadataHostBuilderExtensions

Extensions for application metadata.

BackgroundService

Base class for implementing a long running IHostedService.

ConsoleLifetimeOptions

Provides option flags for ConsoleLifetime.

EnvironmentName

Commonly used environment names.

This type is obsolete and will be removed in a future version. The recommended alternative is Microsoft.Extensions.Hosting.Environments.

Environments

Commonly used environment names.

FakeHostingExtensions

Extension methods supporting host unit testing scenarios.

Host

Provides convenience methods for creating instances of IHostBuilder with pre-configured defaults.

HostAbortedException

The exception that is thrown upon IHost abortion.

HostApplicationBuilder

Represents a hosted applications and services builder that helps manage configuration, logging, lifetime, and more.

HostApplicationBuilderSettings

Settings for constructing an HostApplicationBuilder.

HostBuilder

A program initialization utility.

HostBuilderContext

Context containing the common services on the IHost. Some properties may be null until set by the IHost.

HostDefaults

Constants for HostBuilder configuration keys.

HostEnvironmentEnvExtensions

Extension methods for IHostEnvironment.

HostingAbstractionsHostBuilderExtensions

Provides extension methods for the IHostBuilder from the hosting abstractions package.

HostingAbstractionsHostExtensions

Provides extension methods for the IHost from the hosting abstractions package.

HostingEnvironmentExtensions

Extension methods for IHostingEnvironment.

HostingHostBuilderExtensions

Provides extension methods for the IHostBuilder from the hosting package.

HostOptions

Options for IHost.

SystemdHostBuilderExtensions

Extension methods for setting up SystemdLifetime.

WindowsServiceLifetimeHostBuilderExtensions

Extension methods for setting up WindowsServiceLifetime.

WindowsServiceLifetimeOptions

Options to configure the lifetime of a windows service.

Interfaces

IApplicationLifetime

Allows consumers to perform cleanup during a graceful shutdown.

This type is obsolete and will be removed in a future version. The recommended alternative is Microsoft.Extensions.Hosting.IHostApplicationLifetime.

IHost

A program abstraction.

IHostApplicationBuilder

Represents a hosted applications and services builder which helps manage configuration, logging, lifetime, and more.

IHostApplicationLifetime

Allows consumers to be notified of application lifetime events. This interface is not intended to be user-replaceable.

IHostBuilder

A program initialization abstraction.

IHostedLifecycleService

Defines methods that are run before or after StartAsync(CancellationToken) and StopAsync(CancellationToken).

IHostedService

Defines methods for objects that are managed by the host.

IHostEnvironment

Provides information about the hosting environment an application is running in.

IHostingEnvironment

Provides information about the hosting environment an application is running in.

This type is obsolete and will be removed in a future version. The recommended alternative is Microsoft.Extensions.Hosting.IHostEnvironment.

IHostLifetime

Tracks host lifetime.

Enums

BackgroundServiceExceptionBehavior

Specifies a behavior that the IHost will honor if an unhandled exception occurs in one of its BackgroundService instances.