. NET Enterprise Development: Build a Windows Service Program

Source: Internet
Author: User

Using. Net to develop Windows Services is particularly simple. vs2005 has integrated Windows service project templates.

All Windows Services are encapsulated inSystem. serviceprocessProgramCentralized.

Main categories:

1. servicebase: The base class of all Windows Services. Generally, the service we create must inherit from it. The most important class. Its EventLog attribute can write logs to the system. The corresponding eventsource will be created during installation

2. serviceinstaller: Service Installation class, which controls some settings during service installation, such as name, description, starttype, servicedependedon...

3. serviceprocessinstaller: used to set the service process account during installation.

For the classes 2nd and 3, right-click the service class> add installer in vs to automatically generate the class. You only need to modify the relevant attributes.

After creating a service project, you can create an installation service project to automatically install the service to the target machine.

You can also install the SDK manually. The SDK command is installutil <services. dll>. Please include a parameter/u during reverse installation.

 

An example program is provided for your reference.

Demowindowsservice.zip

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.