对 Windows 服务使用调试视图 [英] Using Debug View with a Windows Service

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

问题描述

我在远程机器上实时调试 Windows 服务时遇到问题.这台机器位于防火墙后面,只能通过远程桌面访问.我在我的代码中包含了 Debug.WriteLine 语句,代替了 Console.WriteLine.不久前,我遇到了一个来自 Microsoft 的应用程序,名为 调试视图.它有助于调试 Forms 和 WPF 应用程序,但它不会显示正在运行的服务的 Debug.WriteLine 语句.如果我能看到这些调试语句,我会非常高兴.有没有办法做到这一点?

I'm having trouble with real time debugging of a Windows service on a remote machine. This machine is behind a firewall only accessible through remote desktop. I include Debug.WriteLine statements through my code, in lieu of Console.WriteLine. Not too long ago I ran across an application from Microsoft named Debug View. It has been helpful in debugging Forms and WPF applications but it will not show the Debug.WriteLine statements for a running service. I would be extremely happy if I could see these debug statements. Is there a way to do this?

注意,该项目是在调试模式下编译的,因为我可以在服务安装过程中在调试视图中看到调试语句.

Note, the project is compiled in debug mode as I can see the debug statements in Debug View during the service installation.

推荐答案

Run Debug View as Administrator,选择 Capture 菜单,然后确保选中 Capture Global Win32.这将从您的服务(以及任何其他服务)中捕获 Debug.WriteLine 输出.您可能希望使用过滤器来防止 Debug View 显示您不感兴趣的输出.考虑在您的服务调试消息前加上您的服务名称,以便您可以对其进行过滤.

Run Debug View as Administrator, select the Capture menu, then make sure that Capture Global Win32 is checked. That will capture Debug.WriteLine output from your service (and any other service as well). You may want to use a filter to prevent Debug View from displaying output you are not interested in. Consider prefixing your service debug messages with your service name so that you can filter for them.

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

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