Under Windows Service Console to start with debugging state

Recently been using the service, discovery service is not as difficult to debug.

Under Windows Service Console to start with debugging state: step two steps

The first step to change the Program, the startup code

    static  class Program 
    { 
        ///  <Summary> 
        /// main entry point for the application.
        ///  </ Summary> 
        static  void the Main ( String [] args) 
        { 
            IF (Environment.UserInteractive) 
            { 
                // perform interactively 
                var Test = new new MyChatService (); 
                test.TestStartupAndStop (args); 
            } 
            the else 
            { 
                the ServiceBase [ ] ServicesToRun; 
                ServicesToRun = new new the ServiceBase [] 
                {
                new MyChatService()
                };
                ServiceBase.Run(ServicesToRun);
            }
        }
    }
MyChatService for my service, TestStartupAndStop Code: Start Services in the inside
        public void TestStartupAndStop(string[] args)
        {
            OnStart(args);
            Console.ReadLine();
            OnStop();
        }

 

The second step to modify the project properties = "Console Application

 

 ok, complete.

 

Guess you like

Origin www.cnblogs.com/zhuyapeng/p/11797647.html