显示Windows服务中的消息框 [英] Show a message box from a Windows Service

查看:66
本文介绍了显示Windows服务中的消息框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您可以显示Windows服务中的消息框(或任何形式的通知)吗?无法正常工作.我用过:

Can you display a message box (or any form of notification) from a windows service? Can't get it to work. I used:

            global::System.Windows.Forms.MessageBox.Show("A fatal error occurred. " +
                ServiceName + " is now terminating.");

但是它不起作用,只是产生了一个错误.

but it didn't work and just produced an error.

推荐答案

否,您无法显示服务中的消息框.如果要报告错误,则标准方法是使用

No, you cannot show a message box from a service. If you want to report errors, the standard way to do this is with the event log.

对于更多高级"类型的UI(不仅是错误报告),通常是通过将常规Windows应用程序放入用户的Startup文件夹(或注册表中的Run键)来完成的,通过某种IPC机制(.NET远程处理,WCF,常规套接字,命名管道等)访问服务.

For more "advanced" kinds of UI (not just error reporting), the way this is typically done is via a regular windows application that you put in the user's Startup folder (or the Run key in the registry) and that talks to the service via some kind of IPC mechanism (.NET remoting, WCF, regular sockets, named pipes, etc).

这篇关于显示Windows服务中的消息框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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