ServiceProcessInstaller 클래스

정의

ServiceBase를 확장하는 클래스가 포함된 실행 파일을 설치합니다. 이 클래스는 서비스 애플리케이션을 설치할 때 설치 유틸리티(예: InstallUtil.exe)에서 호출됩니다.

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

예제

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

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

일반적으로 프로젝트 설치 관리자 클래스를 명시적으로 인스턴스화하지 않습니다. 를 만들고 추가 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

설명

ServiceProcessInstaller 실행 파일의 모든 서비스에 공통적으로 작동합니다. 설치 유틸리티에서 설치하려는 서비스와 연결된 레지스트리 값을 작성하는 데 사용됩니다.

서비스를 설치하려면 에서 Installer상속하는 프로젝트 설치 관리자 클래스를 만들고 클래스true의 를 로 설정합니다RunInstallerAttribute. 프로젝트 내에서 하나를 인스턴스화하고 ServiceProcessInstaller 서비스 애플리케이션을 이전과 인스턴스당 ServiceInstaller 애플리케이션에서 각 서비스에 대 한 인스턴스. 마지막으로 프로젝트 설치 관리자 클래스에 ServiceProcessInstaller instance 및 ServiceInstaller 인스턴스를 추가합니다.

InstallUtil.exe 실행되면 유틸리티는 로 설정된 서비스 어셈블리에서 클래스를 RunInstallerAttributetrue찾습니다. 프로젝트 설치 관리자와 연결된 컬렉션에 클래스를 Installers 추가하여 서비스 어셈블리에 클래스를 추가합니다. 이 이falseRunInstallerAttribute 설치 유틸리티는 프로젝트 설치 관리자를 무시합니다.

인스턴스에 대 한 ServiceProcessInstaller, 속성을 수정할 수 있습니다 로그온 한 사용자 이외의 계정으로 서비스 애플리케이션을 실행는 지정 하 여 포함 합니다. 서비스가 실행되어야 하는 특정 UsernamePassword 쌍을 지정하거나 를 사용하여 Account 컴퓨터의 시스템 계정, 로컬 또는 네트워크 서비스 계정 또는 사용자 계정으로 서비스가 실행되도록 지정할 수 있습니다.

참고

컴퓨터의 시스템 계정이 관리자 계정과 동일하지 않습니다.

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

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

를 인스턴스화 ServiceProcessInstaller 하면 기본 클래스 생성자 가 ComponentInstaller호출됩니다.

생성자

ServiceProcessInstaller()

ServiceProcessInstaller 클래스의 새 인스턴스를 만듭니다.

속성

Account

이 서비스 애플리케이션을 실행할 계정 형식을 가져오거나 설정합니다.

CanRaiseEvents

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

(다음에서 상속됨 Component)
Container

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

(다음에서 상속됨 Component)
Context

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

(다음에서 상속됨 Installer)
DesignMode

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

(다음에서 상속됨 Component)
Events

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

(다음에서 상속됨 Component)
HelpText

서비스 설치 옵션을 설명하는 도움말 텍스트를 가져옵니다.

Installers

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

(다음에서 상속됨 Installer)
Parent

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

(다음에서 상속됨 Installer)
Password

서비스 애플리케이션을 실행하는 사용자 계정과 관련된 암호를 가져오거나 설정합니다.

Site

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

(다음에서 상속됨 Component)
Username

서비스 애플리케이션을 실행하는 사용자 계정을 가져오거나 설정합니다.

메서드

Commit(IDictionary)

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

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

CopyFromComponent(IComponent) 클래스 관련 동작이 포함되지 않는 기본 클래스 ServiceProcessInstaller 메서드를 구현합니다.

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)

지정한 설치 관리자에서 같은 개체를 설치 관리자로 설치했는지 확인합니다.

(다음에서 상속됨 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)

파생 클래스에서 재정의할 때 설치를 제거합니다.

(다음에서 상속됨 Installer)

이벤트

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)

적용 대상

추가 정보