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 服務身分執行時才會啟動。