ServiceInstaller 클래스

정의

ServiceBase를 확장하는 클래스를 설치하여 서비스를 구현합니다. 이 클래스는 서비스 애플리케이션을 설치할 때 설치 유틸리티에서 호출됩니다.

public ref class ServiceInstaller : System::Configuration::Install::ComponentInstaller
public class ServiceInstaller : System.Configuration.Install.ComponentInstaller
type ServiceInstaller = class
    inherit ComponentInstaller
Public Class ServiceInstaller
Inherits ComponentInstaller
상속

예제

다음 예에서는 이라는 프로젝트 설치 관리자를 만듭니다 MyProjectInstaller에서 상속 하는 Installer합니다. 두 가지 서비스를 "Hello World 서비스 1"을 포함 하는 서비스 실행 파일을 가정 하 고 "Hello World 서비스 2". 생성자 내에서 MyProjectInstaller (있는 의해 호출 되는 설치 유틸리티)를 ServiceInstaller 개체는 이러한 각 서비스에 한 및 만들어집니다 ServiceProcessInstaller 실행 파일에 대해 생성 됩니다. 설치 유틸리티를 인식 하도록 MyProjectInstaller 잘못 된 설치 프로그램으로는 RunInstallerAttribute 특성이로 설정 된 true합니다.

선택적 속성은 설치 관리자를 추가 하기 전에 프로세스가 설치 관리자 및 서비스 설치 관리자에서 설정 된 Installers 컬렉션입니다. 설치 유틸리티에 액세스 하는 경우 MyProjectInstaller에 추가 된 개체를 Installers 컬렉션에 대 한 호출을 통해 InstallerCollection.Add 차례로 설치 됩니다. 설치 관리자 프로세스 중 각 백업할 수 있습니다. 차례로 설치 오류가 발생 하므로 개체를 설치한를 나타내는 상태 정보를 유지 합니다.

일반적으로 프로젝트 설치 관리자 클래스의 인스턴스를 명시적으로 만들지 됩니다. 만들 하 고 추가 RunInstallerAttribute 특성 구문의을 설치 유틸리티를 실제로 호출 하 여 인스턴스화합니다 따라서 클래스 이지만 합니다.

#using <System.dll>
#using <System.ServiceProcess.dll>
#using <System.Configuration.Install.dll>

using namespace System;
using namespace System::Collections;
using namespace System::Configuration::Install;
using namespace System::ServiceProcess;
using namespace System::ComponentModel;

[RunInstaller(true)]
public ref class MyProjectInstaller : public Installer
{
private:
    ServiceInstaller^ serviceInstaller1;
    ServiceInstaller^ serviceInstaller2;
    ServiceProcessInstaller^ processInstaller;

public:
    MyProjectInstaller()
    {
        // Instantiate installers for process and services.
        processInstaller = gcnew ServiceProcessInstaller;
        serviceInstaller1 = gcnew ServiceInstaller;
        serviceInstaller2 = gcnew ServiceInstaller;

        // The services run under the system account.
        processInstaller->Account = ServiceAccount::LocalSystem;

        // The services are started manually.
        serviceInstaller1->StartType = ServiceStartMode::Manual;
        serviceInstaller2->StartType = ServiceStartMode::Manual;

        // ServiceName must equal those on ServiceBase derived classes.
        serviceInstaller1->ServiceName = "Hello-World Service 1";
        serviceInstaller2->ServiceName = "Hello-World Service 2";

        // Add installers to collection. Order is not important.
        Installers->Add( serviceInstaller1 );
        Installers->Add( serviceInstaller2 );
        Installers->Add( processInstaller );
    }

    static void Main()
    {
        Console::WriteLine("Usage: InstallUtil.exe [<service>.exe]");
    }
};

int main()
{
    MyProjectInstaller::Main();
}
using System;
using System.Collections;
using System.Configuration.Install;
using System.ServiceProcess;
using System.ComponentModel;

[RunInstaller(true)]
public class MyProjectInstaller : Installer
{
    private ServiceInstaller serviceInstaller1;
    private ServiceInstaller serviceInstaller2;
    private ServiceProcessInstaller processInstaller;

    public MyProjectInstaller()
    {
        // Instantiate installers for process and services.
        processInstaller = new ServiceProcessInstaller();
        serviceInstaller1 = new ServiceInstaller();
        serviceInstaller2 = new ServiceInstaller();

        // The services run under the system account.
        processInstaller.Account = ServiceAccount.LocalSystem;

        // The services are started manually.
        serviceInstaller1.StartType = ServiceStartMode.Manual;
        serviceInstaller2.StartType = ServiceStartMode.Manual;

        // ServiceName must equal those on ServiceBase derived classes.
        serviceInstaller1.ServiceName = "Hello-World Service 1";
        serviceInstaller2.ServiceName = "Hello-World Service 2";

        // Add installers to collection. Order is not important.
        Installers.Add(serviceInstaller1);
        Installers.Add(serviceInstaller2);
        Installers.Add(processInstaller);
    }

    public static void Main()
    {
        Console.WriteLine("Usage: InstallUtil.exe [<service>.exe]");
    }
}
Imports System.Collections
Imports System.Configuration.Install
Imports System.ServiceProcess
Imports System.ComponentModel

<RunInstallerAttribute(True)> _
Public Class MyProjectInstaller
    Inherits Installer
    Private serviceInstaller1 As ServiceInstaller
    Private serviceInstaller2 As ServiceInstaller
    Private processInstaller As ServiceProcessInstaller    
    
    Public Sub New()
        ' Instantiate installers for process and services.
        processInstaller = New ServiceProcessInstaller()
        serviceInstaller1 = New ServiceInstaller()
        serviceInstaller2 = New ServiceInstaller()
        
        ' The services will run under the system account.
        processInstaller.Account = ServiceAccount.LocalSystem
        
        ' The services will be started manually.
        serviceInstaller1.StartType = ServiceStartMode.Manual
        serviceInstaller2.StartType = ServiceStartMode.Manual
        
        ' ServiceName must equal those on ServiceBase derived classes.            
        serviceInstaller1.ServiceName = "Hello-World Service 1"
        serviceInstaller2.ServiceName = "Hello-World Service 2"
        
        ' Add installers to collection. Order is not important.
        Installers.Add(serviceInstaller1)
        Installers.Add(serviceInstaller2)
        Installers.Add(processInstaller)
    End Sub

    Public Shared Sub Main()
        Console.WriteLine("Usage: InstallUtil.exe [<service>.exe]")
    End Sub
End Class

설명

ServiceInstaller 와 연관 된 서비스에 특정 된 작동 합니다. 다음 레지스트리 키 내에서 하위 서비스와 관련 된 레지스트리 값을 쓸 설치 유틸리티에서 사용 됩니다. 서비스는이 하위 키는 내에서 해당 ServiceName로 식별 됩니다. 하위 키에는 실행 파일 또는.dll 서비스가 속한 이름도 포함 됩니다.

서비스를 설치 하려면에서 상속 되는 프로젝트 설치 관리자 클래스를 만듭니다는 Installer 클래스를 설정 합니다 RunInstallerAttribute 클래스를 특성 true합니다. 프로젝트 내에서 하나를 만들 ServiceProcessInstaller 서비스 애플리케이션을 이전과 인스턴스당 ServiceInstaller 애플리케이션에서 각 서비스에 대 한 인스턴스. 프로젝트 설치 관리자 클래스 생성자를 사용 하 여 서비스에 대 한 설치 속성을 설정 합니다 ServiceProcessInstaller 하 고 ServiceInstaller 인스턴스와 인스턴스를 추가할는 Installers 컬렉션.

참고

설치 관리자 인스턴스를 추가 하는 것에 대 한 생성자를 사용 하는 것이 좋습니다. 그러나에 추가 해야 할 경우는 Installers 컬렉션에는 Install 메서드를 컬렉션에 동일한 추가 수행 해야 합니다 Uninstall 메서드.

파생 된 모든 클래스에 대 한 합니다 Installer 클래스의 상태는 Installers 컬렉션에서 동일 해야 합니다 InstallUninstall 메서드. 그러나 컬렉션을 유지 관리를 방지할 수 있습니다 합니다 InstallUninstall 설치 관리자 인스턴스를 추가 하는 경우 메서드는 Installers 사용자 지정 설치 관리자 클래스 생성자 컬렉션입니다. 설치 유틸리티를 호출 하는 때를 찾습니다는 RunInstallerAttribute 특성입니다. 특성이 있으면 true, 유틸리티에 추가 된 서비스를 모두 설치 된 Installers 프로젝트 설치 관리자를 사용 하 여 연결 된 컬렉션입니다. 하는 경우 RunInstallerAttributefalse 또는 존재 하지는 설치 유틸리티 프로젝트 설치 관리자를 무시 합니다.

합니다 ServiceProcessInstaller 관련 된 설치 클래스 설치 프로젝트 정보 모두에 공통적으로 적용 ServiceInstaller 프로젝트의 인스턴스. 이 서비스는 설치 프로젝트의 다른 서비스에서 구분 하는 모든 항목에 해당 서비스 관련 정보는이 메서드에 의해 설치 됩니다.

참고

것이 중요 하는 ServiceName 와 동일할 수는 ServiceBase.ServiceName 에서 파생 된 클래스의 ServiceBase. 일반적으로 값을 ServiceBase.ServiceName 서비스 애플리케이션의 실행 파일의 main () 함수 내에서 서비스 속성 설정 됩니다. 서비스 제어 관리자를 사용 하 여 ServiceInstaller.ServiceName 이 실행 파일 내에서 서비스를 찾을 속성입니다.

다른 속성을 수정할 수 있습니다는 ServiceInstaller 전후에 추가 하는 Installers 프로젝트 설치 관리자의 컬렉션입니다. 예를 들어, 서비스의 StartType 재부팅 시 자동으로 서비스를 시작 하거나 서비스를 수동으로 시작 되도록 사용자로 설정할 수 있습니다.

메서드를 호출 하는 되는 일반적으로 ServiceInstaller 코드 내에서 일반적으로 라고 설치 유틸리티에서만 합니다. 설치 유틸리티를 자동으로 호출 합니다 ServiceProcessInstaller.InstallServiceInstaller.Install 설치 프로세스 중 메서드. 원하는를 필요한 경우 호출 하 여 Rollback (또는 ServiceInstaller.Rollback)에서 이전에 설치 된 모든 구성 요소입니다.

설치 유틸리티 호출 Uninstall 개체를 제거 합니다.

프로젝트 설치 관리자를 사용 하 여 구성 요소가 이미 설치 되어 자동으로 정보를 유지 하는 애플리케이션의 설치 루틴 Installer.Context합니다. 이 상태 정보는 지속적으로 업데이트 합니다 ServiceProcessInstaller 인스턴스를 만들고 각 ServiceInstaller 인스턴스가 유틸리티에 의해 설치 된. 상태 정보를 명시적으로 수정 하기 위해 코드에 대 한 일반적으로 필요는 없습니다.

자동으로 만듭니다 설치를 수행 하는 경우는 EventLogInstaller 와 연결 된 이벤트 로그 소스를 설치 하는 ServiceBase 클래스를 파생 합니다. 합니다 Log 에서이 원본에 대 한 속성을 설정 합니다 ServiceInstaller 컴퓨터의 애플리케이션 로그에는 생성자입니다. 설정한 경우는 ServiceNameServiceInstaller (동일 해야 합니다 ServiceBase.ServiceName 서비스의), Source 동일한 값으로 자동으로 설정 됩니다. 설치 오류가 소스의 설치에서는 이전에 설치 된 서비스와 함께 롤백된입니다.

Uninstall 메서드를 실행 하는 경우 서비스를 중지 하려고 합니다. 여부에 상관 없이 여부 Uninstall 에서 변경한 내용을 실행 취소 Install합니다. 이벤트 로깅에 대 한 새 소스를 만든 경우 원본이 삭제 됩니다.

생성자

ServiceInstaller()

ServiceInstaller 클래스의 새 인스턴스를 초기화합니다.

속성

CanRaiseEvents

구성 요소가 이벤트를 발생시킬 수 있는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 Component)
Container

IContainer을 포함하는 Component를 가져옵니다.

(다음에서 상속됨 Component)
Context

현재 설치에 대한 정보를 가져오거나 설정합니다.

(다음에서 상속됨 Installer)
DelayedAutoStart

자동으로 시작된 다른 서비스가 실행되는 동안 서비스 시작을 지연할지 여부를 나타내는 값을 가져오거나 설정합니다.

Description

서비스에 대한 설명을 가져오거나 설정합니다.

DesignMode

Component가 현재 디자인 모드인지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 Component)
DisplayName

사용자가 서비스를 식별하는 데 사용되는 이름을 나타냅니다.

Events

Component에 연결된 이벤트 처리기의 목록을 가져옵니다.

(다음에서 상속됨 Component)
HelpText

설치 관리자 컬렉션에 있는 모든 설치 관리자에 대한 도움말 텍스트를 가져옵니다.

(다음에서 상속됨 Installer)
Installers

이 설치 관리자에 포함된 설치 관리자 컬렉션을 가져옵니다.

(다음에서 상속됨 Installer)
Parent

이 설치 관리자가 속한 컬렉션을 포함하는 설치 관리자를 가져오거나 설정합니다.

(다음에서 상속됨 Installer)
ServiceName

시스템에서 이 서비스를 식별하는 데 사용되는 이름을 나타냅니다. 이 속성은 설치하려는 서비스의 ServiceName과 동일해야 합니다.

ServicesDependedOn

이 서비스를 실행하는 데 필요한 서비스를 나타냅니다.

Site

ComponentISite를 가져오거나 설정합니다.

(다음에서 상속됨 Component)
StartType

이 서비스를 시작하는 방법 및 시기를 나타냅니다.

메서드

Commit(IDictionary)

파생 클래스에서 재정의할 때 설치 트랜잭션을 완료합니다.

(다음에서 상속됨 Installer)
CopyFromComponent(IComponent)

ServiceBase 인스턴스의 속성을 이 설치 관리자에 복사합니다.

CreateObjRef(Type)

원격 개체와 통신하는 데 사용되는 프록시 생성에 필요한 모든 관련 정보가 들어 있는 개체를 만듭니다.

(다음에서 상속됨 MarshalByRefObject)
Dispose()

Component에서 사용하는 모든 리소스를 해제합니다.

(다음에서 상속됨 Component)
Dispose(Boolean)

Component에서 사용하는 관리되지 않는 리소스를 해제하고, 관리되는 리소스를 선택적으로 해제할 수 있습니다.

(다음에서 상속됨 Component)
Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetLifetimeService()
사용되지 않음.

이 인스턴스의 수명 정책을 제어하는 현재의 수명 서비스 개체를 검색합니다.

(다음에서 상속됨 MarshalByRefObject)
GetService(Type)

Component 또는 해당 Container에서 제공하는 서비스를 나타내는 개체를 반환합니다.

(다음에서 상속됨 Component)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
InitializeLifetimeService()
사용되지 않음.

이 인스턴스의 수명 정책을 제어하는 수명 서비스 개체를 가져옵니다.

(다음에서 상속됨 MarshalByRefObject)
Install(IDictionary)

서비스 애플리케이션 정보를 레지스트리에 기록하여 서비스를 설치합니다. 이 메서드는 적절한 메서드를 자동으로 처리하는 설치 도구에서 사용됩니다.

IsEquivalentInstaller(ComponentInstaller)

두 개의 설치 관리자가 동일한 서비스를 설치하는지 여부를 나타냅니다.

MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
MemberwiseClone(Boolean)

현재 MarshalByRefObject 개체의 단순 복사본을 만듭니다.

(다음에서 상속됨 MarshalByRefObject)
OnAfterInstall(IDictionary)

AfterInstall 이벤트를 발생시킵니다.

(다음에서 상속됨 Installer)
OnAfterRollback(IDictionary)

AfterRollback 이벤트를 발생시킵니다.

(다음에서 상속됨 Installer)
OnAfterUninstall(IDictionary)

AfterUninstall 이벤트를 발생시킵니다.

(다음에서 상속됨 Installer)
OnBeforeInstall(IDictionary)

BeforeInstall 이벤트를 발생시킵니다.

(다음에서 상속됨 Installer)
OnBeforeRollback(IDictionary)

BeforeRollback 이벤트를 발생시킵니다.

(다음에서 상속됨 Installer)
OnBeforeUninstall(IDictionary)

BeforeUninstall 이벤트를 발생시킵니다.

(다음에서 상속됨 Installer)
OnCommitted(IDictionary)

Committed 이벤트를 발생시킵니다.

(다음에서 상속됨 Installer)
OnCommitting(IDictionary)

Committing 이벤트를 발생시킵니다.

(다음에서 상속됨 Installer)
Rollback(IDictionary)

설치 프로시저에서 레지스트리에 쓴 서비스 애플리케이션 정보를 롤백합니다. 이 메서드는 적절한 메서드를 자동으로 처리하는 설치 도구에서 사용됩니다.

ToString()

Component의 이름이 포함된 String을 반환합니다(있는 경우). 이 메서드는 재정의할 수 없습니다.

(다음에서 상속됨 Component)
Uninstall(IDictionary)

레지스트리에서 서비스에 대한 정보를 제거하여 해당 서비스를 제거합니다.

이벤트

AfterInstall

Installers 속성의 모든 설치 관리자에 대한 Install(IDictionary) 메서드가 실행된 후에 발생합니다.

(다음에서 상속됨 Installer)
AfterRollback

Installers 속성의 모든 설치 관리자에 대한 설치가 롤백된 후에 발생합니다.

(다음에서 상속됨 Installer)
AfterUninstall

Installers 속성의 모든 설치 관리자가 제거 작업을 수행한 후에 발생합니다.

(다음에서 상속됨 Installer)
BeforeInstall

설치 관리자 컬렉션에 있는 각 설치 관리자의 Install(IDictionary) 메서드가 실행되기 전에 발생합니다.

(다음에서 상속됨 Installer)
BeforeRollback

Installers 속성의 설치 관리자가 롤백되기 전에 발생합니다.

(다음에서 상속됨 Installer)
BeforeUninstall

Installers 속성의 설치 관리자가 제거 작업을 수행하기 전에 발생합니다.

(다음에서 상속됨 Installer)
Committed

Installers 속성의 모든 설치 관리자가 설치를 커밋한 후에 발생합니다.

(다음에서 상속됨 Installer)
Committing

Installers 속성의 설치 관리자가 설치를 커밋하기 전에 발생합니다.

(다음에서 상속됨 Installer)
Disposed

Dispose() 메서드를 호출하여 구성 요소를 삭제할 때 발생합니다.

(다음에서 상속됨 Component)

적용 대상

추가 정보