Debug Windows Service program in C#

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
RadhaKrishnaKiJayaAsked:
Who is Participating?
 
LucasConnect With a Mentor 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.
0
 
ste5anSenior DeveloperCommented:
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.
0
 
RadhaKrishnaKiJayaAuthor Commented:
Hello ste5an,
Thank you!  Do you have any sample code?

Thank you!
0
 
RadhaKrishnaKiJayaAuthor Commented:
Thank you Lucas.  That worked.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.