Upravit

Sdílet prostřednictvím


ServiceInstaller Constructor

Definition

Initializes a new instance of the ServiceInstaller class.

public:
 ServiceInstaller();
public ServiceInstaller ();
Public Sub New ()

Remarks

To install a service, create a project installer class that inherits from the Installer class, and set the RunInstallerAttribute attribute on the class to true. Within your project, create one ServiceProcessInstaller instance per service application, and one ServiceInstaller instance for each service in the application. Within your project installer class constructor, set the installation properties for the service using the ServiceProcessInstaller and ServiceInstaller instances, and add the instances to the Installers collection.

The ServiceInstaller constructor automatically generates an event log source whose Log property is set to the computer's Application log, and an EventLogInstaller. When you set the ServiceName of the ServiceInstaller, which should be identical to the ServiceBase.ServiceName of the service, the Source property of the event log is automatically set to the same value. The source is deleted automatically in the case of an installation failure.

The ServiceInstaller constructor sets the StartType property to ServiceStartMode.Manual to specify that a user start the service. You can reset the property to ServiceStartMode.Automatic to specify that the service start when the computer reboots.

Applies to

See also