如何从与桌面交互的应用程序与 Windows 服务进行通信? [英] How to communicate with a windows service from an application that interacts with the desktop?

查看:26
本文介绍了如何从与桌面交互的应用程序与 Windows 服务进行通信?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 .Net 与服务交互的最佳方式是什么(即大多数托盘应用程序如何与其服务器通信).如果这种方法也是跨平台的,那将是首选(在 Mono 中工作,所以我猜远程处理已经过时了?)

With .Net what is the best way to interact with a service (i.e. how do most tray-apps communicate with their servers). It would be preferred if this method would be cross-platform as well (working in Mono, so I guess remoting is out?)

忘了说,我们在现场还是要支持Windows 2000机器,所以WCF和.Net 2.0以上的任何东西都不会飞.

Forgot to mention, we still have to support Windows 2000 machines in the field, so WCF and anything above .Net 2.0 won't fly.

推荐答案

请注意,如果您计划最终在 Windows Vista 或 Windows Server 2008 上进行部署,那么今天可以完成的许多方法将不起作用.这是因为引入了称为会话 0 隔离"的新安全功能.

Be aware that if you are planning to eventually deploy on Windows Vista or Windows Server 2008, many ways that this can be done today will not work. This is because of the introduction of a new security feature called "Session 0 Isolation".

大多数 Windows 服务现在已移至会话 0 中运行,以便将它们与系统的其余部分正确隔离.对此的扩展是,第一个登录系统的用户不再被放置在会话 #0 中,他们被放置在会话 1 中.因此,隔离将破坏在服务和桌面应用程序之间进行某些类型的通信的代码.

Most windows services have been moved to run in Session 0 now in order to properly isolate them from the rest of the system. An extension of this is that the first user to login to the system no longer is placed in Session #0, they are placed in Session 1. And hence, the isolation will break code that does certain types of communication between services and desktop applications.

在服务和应用程序之间进行通信时,目前编写适用于 Vista 和 Server 2008 的代码的最佳方法是使用适当的跨进程 API,如 RPC、命名管道等.不要使用 SendMessage/PostMessage因为这将在会话 0 隔离下失败.

The best way to write code today that will work on Vista and Server 2008 going forward when doing communication between services and applications is to use a proper cross-process API like RPC, Named Pipes, etc. Do not use SendMessage/PostMessage as that will fail under Session 0 Isolation.

http://www.microsoft.com/whdc/system/vista/服务.mspx

现在,根据您的要求,您将陷入困境.对于跨平台问题,我不确定是否支持远程处理.您可能必须下拉并一直回到套接字:http://msdn.microsoft.com/en-us/library/system.net.sockets.aspx

Now, given your requirements, you are going to be in a bit of a pickle. For the cross-platform concerns, I'm not sure if Remoting would be supported. You may have to drop down and go all the way back to sockets: http://msdn.microsoft.com/en-us/library/system.net.sockets.aspx

这篇关于如何从与桌面交互的应用程序与 Windows 服务进行通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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