How to: Add Installers to Your Service Application
Visual Studio ships installation components that can install resources associated with your service applications. Installation components register an individual service on the system to which it is being installed and let the Services Control Manager know that the service exists. When you work with a service application, you can select a link in the Properties window to automatically add the appropriate installers to your project.
Property values for your service are copied from the service class to the installer class. If you update the property values on the service class, they are not automatically updated in the installer.
When you add an installer to your project, a new class (which, by default, is named
ProjectInstaller) is created in the project, and instances of the appropriate installation components are created within it. This class acts as a central point for all of the installation components your project needs. For example, if you add a second service to your application and click the Add Installer link, a second installer class is not created; instead, the necessary additional installation component for the second service is added to the existing class.
You do not need to do any special coding within the installers to make your services install correctly. However, you may occasionally need to modify the contents of the installers if you need to add special functionality to the installation process.
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Personalize the Visual Studio IDE.
To add installers to your service application
In Solution Explorer, access Design view for the service for which you want to add an installation component.
Click the background of the designer to select the service itself, rather than any of its contents.
With the designer in focus, right-click, and then click Add Installer.
A new class,
ProjectInstaller, and two installation components, ServiceProcessInstaller and ServiceInstaller, are added to your project, and property values for the service are copied to the components.
Value Result Manual The service must be manually started after installation. For more information, see How to: Start Services. Automatic The service will start by itself whenever the computer reboots. Disabled The service cannot be started.
To determine the security context in which your service will run, click the ServiceProcessInstaller component and set the appropriate property values. For more information, see How to: Specify the Security Context for Services.
Override any methods for which you need to perform custom processing.
Perform steps 1 through 7 for each additional service in your project.