Debugging method of Windowsservice

Source: Internet
Author: User

I reprint: http://www.cnblogs.com/xiebin1986/archive/2011/12/15/2288893.html

Debugging Windowsservice, previously used a method attached to the process, or is quite troublesome, need to install and start the service, and later found a better method, the method is as follows:

Add the following code to the Service1.cs (or Other startup Class):

public static void Main (string[] args)
{
Service1 s = new Service1 ();
S.onstart (NULL);
Console.ReadLine ();
S.onstop ();
}

Then make the following changes in the project properties:

Windowsservice Project--"attribute--" Output type to: Console application.

Windowsservice Project--"attribute--" Start object to: Service1.

Then you can run it for debugging!

Be sure to change it back when you're officially deployed!

Second, the new unit test project is also a good solution.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.