Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Debug Windows Service program in C#

Posted on 2016-10-01
4
43 Views
Last Modified: 2016-10-06
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
0
Comment
Question by:RadhaKrishnaKiJaya
  • 2
4 Comments
 
LVL 33

Expert Comment

by:ste5an
ID: 41824988
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
 

Author Comment

by:RadhaKrishnaKiJaya
ID: 41824996
Hello ste5an,
Thank you!  Do you have any sample code?

Thank you!
0
 
LVL 2

Accepted Solution

by:
Lucas earned 500 total points
ID: 41825639
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
 

Author Closing Comment

by:RadhaKrishnaKiJaya
ID: 41833023
Thank you Lucas.  That worked.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question