1. New Windows Service Project
2. Add business logic code on Service1.cs
3. After you complete the code, remember to add the installer, or you cannot register as a Windows service
Description Description of the corresponding service, the name of the servicename corresponding service
Account Select LocalSystem
4. Click Create Solution
5, the service program is located in the directory do not have spaces, you can copy the generated program
6. Registering the program with the window service
1) Open command Console, enter CMD after windows+r
2) CD C:\Windows\Microsoft.NET\Framework\v4.0.30319 is the same directory as. NET, different versions of different directories
3) InstallUtil.exe% service directory + Service exe file%. If you uninstall the service, add/U after InstallUtil.exe
Normal words should be visible in Windows services.
7. Start the Windows service
8. Select attach to process in the Debug menu
Select the service process and click Attach.
9 Add Debugger.launch () to the OnStart method; This allows the service to enter the breakpoint immediately after it is started
10 Restart the Windows service to see the debug interface
If you choose Yes, you're going to break.
VISUAL STUDIO 2015 creating Windows Services and debugging