Debug Windows Service program in C#

RadhaKrishnaKiJaya
RadhaKrishnaKiJaya used Ask the Experts™
on
Hello Experts,
I want to Debug a  Windows Service program.  Any idea how can I do that?  When I do it by hitting F5, it works till a point.  After that I get the attached message.  Please help.  Thank you in advance.

Thank you!
DebugWindowsService.png
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
ste5anSenior Developer

Commented:
It depends on the concrete code and situation..

I develop service code as a class library. Thus allows to use unit test and to create a console application to test the code.

Also use a loging framework like EntLib Logging or  log4net. And https://support.microsoft.com/en-us/kb/815788traces are also an option.

Author

Commented:
Hello ste5an,
Thank you!  Do you have any sample code?

Thank you!
Commented:
Hello,

you can follow the instructions given here:
Debugging Tips for Windows Services

in short, you will create a method to test the startup and the stop method of your service, and changing the output type to Console Application.

Author

Commented:
Thank you Lucas.  That worked.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial