29 Ekim 2013 Salı

Create Windows Service in Visual Studio [C#]

Sponsorlu Bağlantılar
This example shows step-by-step how to create a windows service in Visual Studio 2005.
Create new project and select windows service (Visual C# / Windows / Windows Service). Enter the project name, e.g. „MyService“.
New Project – Windows Service
View designer of the Service1.cs and click to Add Installer in the Properties window.
Windows Service – Add Installer
It adds a ProjectInstaller­.cs file to the project. This file contains two components, a ServiceInsta­ller and a ServiceProces­sInstaller.
Click to serviceInstaller1 and in the Properties window set ServiceName to „MyService“, change DisplayName (shown in Microsoft Management Console) and fill in the Descriptionfield. You can also set StartType to automatic or manual service starting.
Service Installer – Properties
Click to serviceProces­sInstaller1 and change the Account property to a value you need. It's an account under which the system runs the service. Account descriptions can be found inServiceAccount enumeration.
Service Process Installer – Properties
Complete the implementation of OnStart and OnStop methods in the service class.
Service Code

Sponsorlu Bağlantılar

Hiç yorum yok:

Yorum Gönder