What is the best way to debug a Windows Service program in Visual Studio 2008

I am using Microsoft magazine Parser in a windows service. The program runs on a regular web page, but when I put the code in a Windows service, it does not work. I put Breakponts in a Windows service, but when I run the code, the program does not stop at the breakpoint. Therefore, fixing the problems, I narrowed down the problem to Log Parser and Linq software. Therefore, either Linq or the log analyzer software creates a problem. Do you have any ideas?

+5
source share
4 answers

I have done this many times in the past, depending on how the program works. I think that the easiest way is done with the ifDEBUG preprocessor directive around Debugger.Launch () so that when you build a project optimized for calling Debugger.Launch (), it will not be compiled into the assembly.

One of the ways we also did this task with System.Windows.Forms.MessageBox.Show ("attach"), which allowed us to manually attach to the debugger whenever the "attach" dialog was displayed.

, , - . , , ServiceBase.Run , - , , / .

+2

OnStart? , System.Diagnostics.Debugger.Launch()   System.Diagnostics.Debugger.Break(), , start, .

+2

I think the thick suggestion of attaching your debugger to the maintenance process sounds right. If this still does not work, try using Debug.WriteLine and DebugView .

+2
source

All Articles