Local modal windows service

first step:

OnStart method to find the service master class by

protected override void OnStart(string[] args)

{

  //todo something

}

changed to

public void OnStart()

{

   //todo something

 

Step two:

Program.cs file comment out the following code:

ServiceBase [] ServicesToRun;

ServicesToRun = new ServiceBase[] 

new Service1() 

};

ServiceBase.Run(ServicesToRun);

changed to

Service1 s1 = new Service1();

s1.OnStart();

third step:

In OnStart using the method in F9 break point, and then press F5 can be debugged by tracing the code, as shown below:

Guess you like

Origin www.cnblogs.com/1laowang/p/12085279.html