如何使用VS 2012调试Windows服务? [英] How to debug windows service using VS 2012 ?

查看:147
本文介绍了如何使用VS 2012调试Windows服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我在visual studio 2012中创建windows服务。如何调试代码,我的意思是如何使用断点并逐行检查?



我创建服务并使用命令提示符安装,我在vs 2012中尝试附加到进程表单调试菜单,但没有任何反应,我已经在我的代码中放置了断点,并且我在第一行服务中使用下面的代码。

Hi I am create windows service in visual studio 2012.how to debug code,i mean how to use break point and check line by line ?

I am create service and install with command prompt,i try "Attach to Process" form Debug menu in vs 2012,but nothing happen ,i already place break point in my code and also i use below code at first line of service.

System.Diagnostics.Debugger.Launch()



我将配置设置为Debug并停止并启动服务,但没有突破点工作,所以如何调试vs 2012中的服务,请给出一些步骤。



注意:我是使用VS2012安装服务开发人员命令提示符,但仍然无法正常工作。我已经尝试过Microsoft文档。



Windows 8.1中的操作系统



问候



Aravind


I set configuration as "Debug" and i stop and start service ,but didn't break point work, so how to debug service in vs 2012,pls give some steps.

Note: i am install service using VS2012 Developer Command Prompt,but still not work.I already try Microsoft documents.

My OS in windows 8.1

Regards

Aravind

推荐答案

您可以附加和调试您的服务,请检查如何:调试Windows服务应用程序 [ ^ ]

也低于CP提示,为您提供另一种使用控制台应用调试服务的方法:

在Visual Studio下调试Windows服务。 NET [ ^ ]
you can attach and debug your service, check How to: Debug Windows Service Applications[^]
also below CP tip give you another way for debugging your service by using console app:
Debugging Windows Services under Visual Studio .NET[^]


除了解决方案1:



调试服务可能是一个相对困难的问题。我可以分享我发明的方法,特别是轻松调试服务的主要部分。请参阅我之前的回答:使用UI配置Windows服务 [ ^ ]。br />


它过去常常帮助我。特别是,使用我的技术,我设法与第三方供应商合作,对我的服务控制工业硬件进行远程调试,第三方供应商提供他们的密切源代码,从未访问过我们的实验室。



-SA
In addition to Solution 1:

Debugging of the service can be a relatively difficult problem. I can share my approach I invented, in particular, to ease-up debugging of major part of the service. Please see my past answer: Configure Windows Service with UI[^].

It used to help me a lot. In particular, using my technique, I managed to perform remote debugging of my service controlling industrial hardware in collaboration with 3rd-party suppliers who provides their close-source code and never visited our laboratory.

—SA


这篇关于如何使用VS 2012调试Windows服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆