如何调试Windows服务在Visual Studio? [英] How to debug Windows services in Visual Studio?

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

问题描述

是否有可能在Visual Studio调试Windows服务的?

我用code像

  System.Diagnostics.Debugger.Break();

但它给像

一些code错误

  

我有两个事件错误:事件ID 4096
  VsJITDebugger和服务做
  不启动或控制响应
  及时提出要求。



解决方案

您也可以试试这个。


  1. 创建您的Windows服务,并安装和启动...也就是说,Windows服务必须在您的系统中运行。

  2. 当你的服务正在运行,请在调试菜单中,单击附加过程(或旧的Visual Studio程序)

  3. 找到你正在运行的服务,然后从所有用户确保显示进程显示在所有会话工艺选择,如果不然后选择它。

<醇开始=4>
  • 点击连接按钮

  • 点击确定

  • 点击关闭

  • 破发点设置为您的理想地点,等待执行。只要您的code到达该点就会自动调试。

  • 记住,把你的断点可达的地方,如果是的在onStart (),然后停止和启动服务再次

  • (很多谷歌搜索后,我在如何调试在Visual Studio中的Windows服务发现了这个。)

    Is it possible to debug the Windows services in Visual Studio?

    I used code like

    System.Diagnostics.Debugger.Break();
    

    but it is giving some code error like

    I got two event error: eventID 4096 VsJITDebugger and "The service did not respond to the start or control request in a timely fashion. "

    解决方案

    You can also try this.

    1. Create your Windows service and install and start…. That is, Windows services must be running in your system.
    2. While your service is running, go to the Debug menu, click on Attach Process (or process in old Visual Studio)
    3. Find your running service, and then make sure the Show process from all users and Show processes in all sessions is selected, if not then select it.

    1. Click the Attach button
    2. Click OK
    3. Click Close
    4. Set a break point to your desirable location and wait for execute. It will debug automatic whenever your code reaches to that point.
    5. Remember, put your breakpoint at reachable place, if it is onStart(), then stop and start the service again

    (After a lot of googling, I found this in "How to debug the Windows Services in Visual Studio".)

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

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