Windows Serivce Service implementation process and packaged installation

Source: Internet
Author: User
Tags visual studio installer

Environment: vs2013,win7

Reference:

Fast setup and debugging of Windows Services (C # plots)

. NET implements two methods for automatic startup after Windows Service installation is complete

C # build Windows Service Packager

1. New project Windows Service project.

2, the service automatically starts after installation.

Right-click Add Installer

To set some properties of the service. Set the account type for the running service to be a local account.

Set the service name and set startup mode to start automatically.

Note The Display name: is the name of the service that is set to see. In the computer "management" service, see this.

Service Name: Is the setting of the actual services names. This is what you see in the Window Task Manager.

What you see in the Task Manager process is the name of the Windows Service project.

In the ProjectInstaller class, override the parent class commit method

The code is as follows: note the name, which, like the name of the Windows service setting, is set in the ServiceInstaller1 right-click Property

1[Runinstaller (true)]2      Public Partial classProjectInstaller:System.Configuration.Install.Installer3     {4          PublicProjectInstaller ()5         {6 InitializeComponent ();7         }8 9          Public Override voidCommit (IDictionary savedstate)Ten         { One             Base. Commit (savedstate); AServiceController sc =NewServiceController ("Service1"); -             if(SC. Status.equals (servicecontrollerstatus.stopped)) -             { the SC. Start (); -             } -         } -}

3, packaged as EXE files.

VS2013 does not have a packaged project by default and requires download and installation.

Microsoft Visual Studio Installer Projects

After the installation is complete, the solution right-adds a new project, Setup project

ADD, project output

Select your Windows Service project

Right-click on the package item, view, custom action

Each adds a custom action

Final effect

Finally, the installation package can be generated, in the bin directory in debug

After the installation is complete, you can see the service.

Windows serivce Service implementation process and packaging installation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.