Windows 8 中 Windows 服务上的 Debugger.Launch() [英] Debugger.Launch() on windows service in Windows 8

查看:29
本文介绍了Windows 8 中 Windows 服务上的 Debugger.Launch()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我安装完 Windows 8 之后,像这样的完全合法的声明不再起作用了:

After I installed Windows 8 perfectly legit statement like this doesn't work anymore:

#if DEBUG
    Debugger.Launch();
#endif

服务开始忽略那件事.是的,我正在以调试模式构建项目.

Service starts ignoring that thing. Yes, I am building the project in a debug mode.

如果我将其更改为 Debugger.Break() - 服务会失败,但仍然没有用于附加调试器的对话框.

if I change that to a Debugger.Break() - the service just fails, and still there's no dialog for attaching a debugger.

推荐答案

Debugger.Launch 将使用可视 GUI 启动应用程序.默认情况下,服务不与桌面交互,因此它们所做的任何事情都不能被看到".

Debugger.Launch would launch an application with a visual GUI. By default services do not interact with a desktop and thus anything they do cannot be "seen".

对与桌面交互的支持已逐渐从 Windows 服务中删除(例如,与桌面交互"选项已从某些服务器版本中删除).我想他们会继续这种趋势.

Support for interacting with the desktop has slowly been removed from Windows services ("Interact with the desktop" option has been removed from some Server versions for example). I would imagine they've continued this trend.

Windows 服务本质上不是 GUI 应用程序,它们可以在用户登录桌面之前和之后运行,因此 不能一直显示 GUI.依赖于在服务中拥有 GUI 的能力通常不是一个好主意.

Windows Services by nature are not GUI applications, they can run before and after a user logs into a desktop and thus cannot show a GUI all the time. It's not generally a good idea to depend on an ability to have a GUI in a Service.

如果您想做的是调试服务,我建议将其作为常规应用程序运行,这样您就可以执行启动和调试等操作.无耻插件:您可以查看在 Visual Studio 中开发 Windows 服务,了解如何编写支持该功能的服务.

If what you want to do is debug a service, I suggest running it as a regular application so that you can do things like Launch and Debug. Shameless plug: you can see Developing Windows Services in Visual Studio for a way to write a service that supports that.

这篇关于Windows 8 中 Windows 服务上的 Debugger.Launch()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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