WindowsServiceLifetimeHostBuilderExtensions.AddWindowsService Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
AddWindowsService(IServiceCollection) |
Configures the lifetime of the IHost built from |
AddWindowsService(IServiceCollection, Action<WindowsServiceLifetimeOptions>) |
Configures the lifetime of the IHost built from |
AddWindowsService(IServiceCollection)
Configures the lifetime of the IHost built from services
to
WindowsServiceLifetime and enables logging to the event log with the application
name as the default source name.
public:
[System::Runtime::CompilerServices::Extension]
static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddWindowsService(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddWindowsService (this Microsoft.Extensions.DependencyInjection.IServiceCollection services);
static member AddWindowsService : Microsoft.Extensions.DependencyInjection.IServiceCollection -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddWindowsService (services As IServiceCollection) As IServiceCollection
Parameters
- services
- IServiceCollection
The IServiceCollection used to build the IHost. For example, Services or the IServiceCollection passed to the ConfigureServices(Action<HostBuilderContext,IServiceCollection>) callback.
Returns
The services
instance for chaining.
Remarks
This is context aware and will only activate if it detects the process is running as a Windows Service.
Applies to
AddWindowsService(IServiceCollection, Action<WindowsServiceLifetimeOptions>)
Configures the lifetime of the IHost built from services
to
WindowsServiceLifetime and enables logging to the event log with the application name as the default source name.
public:
[System::Runtime::CompilerServices::Extension]
static Microsoft::Extensions::DependencyInjection::IServiceCollection ^ AddWindowsService(Microsoft::Extensions::DependencyInjection::IServiceCollection ^ services, Action<Microsoft::Extensions::Hosting::WindowsServiceLifetimeOptions ^> ^ configure);
public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddWindowsService (this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Action<Microsoft.Extensions.Hosting.WindowsServiceLifetimeOptions> configure);
static member AddWindowsService : Microsoft.Extensions.DependencyInjection.IServiceCollection * Action<Microsoft.Extensions.Hosting.WindowsServiceLifetimeOptions> -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function AddWindowsService (services As IServiceCollection, configure As Action(Of WindowsServiceLifetimeOptions)) As IServiceCollection
Parameters
- services
- IServiceCollection
The IServiceCollection used to build the IHost. For example, Services or the IServiceCollection passed to the ConfigureServices(Action<HostBuilderContext,IServiceCollection>) callback.
- configure
- Action<WindowsServiceLifetimeOptions>
An Action<T> to configure the provided WindowsServiceLifetimeOptions.
Returns
The services
instance for chaining.
Remarks
This is context aware and will only activate if it detects the process is running as a Windows Service.