如何调试使用断点窗口服务? [英] How to debug a windows service using breakpoints?
问题描述
我有一个窗口服务,一个计时器。它很难调试。因为我启动该服务,投放的code不同部位突破点。当我附上的过程中,我预计该服务从一开始,而不是在中间code在那里我有破发点一些randome的地方开始。它很难调试像一个正常的应用程序,你知道的起点。似乎有在尚未完成回地面流程。所以,每一次,我开始调试,而不是从第一个破发点开始,它从应用程序的中间一些随机破发点开始。
I have a windows service with a timer. Its very hard to debug it. Because I start the service and put break points in different parts of the code. When I attach the process, I expect the service to start from the very beginning instead of some randome place in the middle code where I have break points. Its hard to debug like a normal application where you know the starting point. It appears that there are processes in the back ground that have not completed yet. So every single time, I start to debug, instead of starting from the very first break point, it starts from some random break point in the middle of application.
我想知道如何窗口服务工作中的进程,线程等方面......我怎么能从头开始调试?
I want to know how windows service works in terms of processes, threads etc... and how can I start debugging from the beginning?
推荐答案
我假设你是在谈论,当然.NET。我一直用下面的code调试我的服务。我把它放在我想调试器来启动。启动该服务,它会自动启动Visual Studio中。很适合我。
I assume you're talking about .Net of course. I've always used the following code to debug my services. I place it where I want to the debugger to launch. Start the service and it automatically launches Visual Studio. Works well for me.
System.Diagnostics.Debugger.Launch();
System.Diagnostics.Debugger.Debug();
这篇关于如何调试使用断点窗口服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!