WindowsServiceLifetimeHostBuilderExtensions.AddWindowsService 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
重载
AddWindowsService(IServiceCollection) |
配置从 |
AddWindowsService(IServiceCollection, Action<WindowsServiceLifetimeOptions>) |
配置从 |
AddWindowsService(IServiceCollection)
配置从 services
生成到 WindowsServiceLifetime 的 IHost 的生存期,并启用使用应用程序名称作为默认源名称登录到事件日志。
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
参数
- services
- IServiceCollection
用于生成 IHost的 IServiceCollection。 例如,Services 或传递给 ConfigureServices(Action<HostBuilderContext,IServiceCollection>) 回调的 IServiceCollection。
返回
用于链接的 services
实例。
注解
这是上下文感知的,仅当它检测到进程作为 Windows 服务运行时才会激活。
适用于
AddWindowsService(IServiceCollection, Action<WindowsServiceLifetimeOptions>)
配置从 services
生成到 WindowsServiceLifetime 的 IHost 的生存期,并启用使用应用程序名称作为默认源名称登录到事件日志。
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
参数
- services
- IServiceCollection
用于生成 IHost的 IServiceCollection。 例如,Services 或传递给 ConfigureServices(Action<HostBuilderContext,IServiceCollection>) 回调的 IServiceCollection。
- configure
- Action<WindowsServiceLifetimeOptions>
返回
用于链接的 services
实例。
注解
这是上下文感知的,仅当它检测到进程作为 Windows 服务运行时才会激活。