[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Debug.Print not printing in a C# service

Posted on 2011-05-11
4
Medium Priority
?
463 Views
Last Modified: 2012-08-13
I include a "Debug.Print (strMessage)" in my Windows Service program.  I can't find the output anywhere, I looked in the output window, immediate window, etc.  Is this feature not supported in a Windows Service?  Do I need to write it to a windows system log?  If there is a way, I would like to write it to one of the windows that I can just view as the processing occurs (rather than lookup in a log file).

0
Comment
Question by:compuzak1
  • 2
  • 2
4 Comments
 
LVL 10

Expert Comment

by:ALaRiva
ID: 35742037
0
 

Author Comment

by:compuzak1
ID: 35742575
Thanks, I will try this if I don't get a response that just uses the Visual Studio system.  

Do you know if you can use Debug.Print in a Windows Service while debugging?  I doubt it since I have to trick the program to acutally enter debug mode before the service actually starts (I call my main processing function).
0
 
LVL 10

Accepted Solution

by:
ALaRiva earned 2000 total points
ID: 35742608
A windows service is not intended for user interaction. You don't run it through Visual Studio, you run it by installing the service to a windows system and then running it. Thus, for debugging/tracing, you can use different options such as writing to an event log, writing to a text file, etc., but IDE output is not an option.

The link I provided kind of skirts around this a bit, but regardless, keep in mind that Windows Service Apps are not intended for user interaction. If that is the case, you need to go with a console app.

Speaking of which, if you really really want to have a console, I've seen tons of examples on how to run a windows service as a console app. Never done it myself, but if you just have to have it, you can also consider that route. I'm not sure of the pros/cons of it though.

hth

- Anthony
0
 

Author Closing Comment

by:compuzak1
ID: 35742636
Thanks for your input.  This is what I thought.

I do not need a console, I am only using the debug.print for testing purposes, it will not be included in the final version.  It just saves time in debugging if you see the values on the screen rather than go to a log file.  

Thanks for your help
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month19 days, 19 hours left to enroll

872 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