To install the service program, follow these steps:
Add the installer to the Service Application
1. In Solution Explorer, access the design view of the service for which you want to add and install components.
2. Click the background of the designer to select the service itself, instead of any content.
3. When the design appliance has focus, right-click and click "add installer ".
In this case, a new ProjectInstaller class and two installation components ServiceProcessInstaller and ServiceInstaller are added to the project, and the service attribute values are copied to the component.
4. Click the ServiceInstaller component to verify that the value of the ServiceName attribute is the same as that of the ServiceName attribute of the service.
5. To determine how to start the service, click the ServiceInstaller component and set the StartType attribute to an appropriate value.
StartType:
Value result
Manual
After the service is installed, you must start it manually. For more information, see How to: Start a service.
Automatic
The service is automatically started every time the computer restarts.
Disabled
The service cannot be started.
5. To determine the security context of the service to be run, click the ServiceProcessInstaller component and set the appropriate attribute value. (For example, if you want to use a system user, select LocalSystem instead of user)
7. rewrite all methods for which custom processing is required.
8. Create your installation project and custom Operations to deploy and install your services.
Follow these steps to complete the installation of the service program. After compilation, you can install the service program.
After the installation is successful, you can open the service in the control panel to check whether the service program you just installed exists.