Create Windows Service in Visual Studio [C#]
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â€ś.
View designer of the Service1.cs and click to Add Installer in the Properties window.
Click to serviceInstaller1 and in the Properties window set ServiceName to â€žMyServiceâ€ś, change DisplayName (shown in Microsoft Management Console) and fill in the Description field. You can also set StartType to automatic or manual service starting.
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 in ServiceAccount enumeration.
Complete the implementation of OnStart and OnStop methods in the serviceÂ class.
- [C#] Install / Uninstall .NET Windows ServiceÂ â€“ how to install .NET services
- [C#] Start, Stop and Restart Windows ServiceÂ â€“ restart a service programmatically
- [C#] Get List of Windows ServicesÂ â€“ get list of installed services
- ServiceInstallerÂ â€“ MSDNÂ â€“ installs a serviceÂ class
- ServiceProcesÂsInstallerÂ â€“ MSDNÂ â€“ installs an executable containing service classes
- ServiceAccountÂ â€“ MSDNÂ â€“ accounts under which the system can run the services