I am using the Microsoft Log Parser in a Windows Service. The program works in a regular web page but when I put the code in a windows service it does not work. I put Breakponts in the windows service but when I run the code the program does not stop at the breakpoint. So through out my troubleshooting I have narrowed the problem down to the Log Parser software and Linq. So either Linq or the log parser software is creating the problem. Do you guys have any idea?
I have done this many ways in the past depending on how the program runs. I think the easiest way is done with a if #DEBUG preprocessor directive around the Debugger.Launch() that way when you've built the project optimized the Debugger.Launch() call won't be compiled into the assembly.
One way we have also done done this task is with System.Windows.Forms.MessageBox.Show("attach") which allowed us to manually attach to the debugger whenever the "attach" dialog was displayed.
The last way which I do not prefer is to change the behavior of your service based on commandline params passed in. Basically opting NOT to start the services using ServiceBase.Run whenever a particular param was fired off, but calling a class that encapsulates the behavior/main function of the service.
You need to attach your debugger directly with Windows Services. This might help you: http://msdn.microsoft.com/en-us/library/7a50syb3%28VS.80%29.aspx.
Do you want to debug the OnStart method? If so you can use System.Diagnostics.Debugger.Launch()
or System.Diagnostics.Debugger.Break()
method to get a chance to attach the debugger while the on start method is running, otherwise you're always to late with attaching the debugger.
I think fat cat's suggestion of attaching your debugger to the service process sounds right. If that still doesn't work, try using Debug.WriteLine and DebugView.
I have done this many ways in the past depending on how the program runs. I think the easiest way is done with a if #DEBUG preprocessor directive around the Debugger.Launch() that way when you've built the project optimized the Debugger.Launch() call won't be compiled into the assembly.
One way we have also done done this task is with System.Windows.Forms.MessageBox.Show("attach") which allowed us to manually attach to the debugger whenever the "attach" dialog was displayed.
The last way which I do not prefer is to change the behavior of your service based on commandline params passed in. Basically opting NOT to start the services using ServiceBase.Run whenever a particular param was fired off, but calling a class that encapsulates the behavior/main function of the service.
Environment.UserInteractive
for this. –
Coopersmith © 2022 - 2024 — McMap. All rights reserved.
Environment.UserInteractive
for this. – Coopersmith