Due to the special nature of Windows Services, its debugging and commonProgramThere are some differences in debugging. Below I will introduce several methods:
1. Recommended Methods by Microsoft
1.1 debug the initialization and startup of Windows Services
Write another program control service initialization and startup
1.2 debug other Windows Services
Is the method to attach the process to the Operating System
2. My TRACE Method
2.1 Add debugging methods
Private Static void debugrun (string [] ARGs)
{
/*
Initialize Service
Onstart ();
Console. Readline ();
Onstop ();
*/
}
2.2 The rewrite program entry is as follows:
Public static void main (string [] ARGs)
{
# If debug
Debugrun (ARGs );
# Else
/*
Initialize Service
*/
# Endif
}
2.3 add two types of debuggingCode
EventLog. writeentry ("...");
System. Diagnostics. Debug. writeline ("...");
Windows Service Development (1. Installation)