简体   繁体   English

我可以在托盘应用程序中托管WCF服务吗

[英]Can I host a wcf service in a tray app

I have a small tray app which should inform the user about start and stop of an execution of an other process running under local system account. 我有一个小托盘应用程序,该应用程序应通知用户有关在本地系统帐户下运行的其他进程的执行的开始和停止。 The process running with local system account is called by another service (not owned by me). 使用本地系统帐户运行的进程由另一个服务(不是我所有)调用。 "My service process" is always running just for a short time. “我的服务流程”始终只运行很短的时间。 So I can not implement a wcf callback handling. 因此,我无法实现wcf回调处理。 Everything works fine on my machine. 我的机器上一切正常。 But it is not running at the customer side. 但是它不在客户端运行。

The problem (exception) which occurs at the customer side is something like "there is no endpoint listening on net.pipe..." 在客户端发生的问题(异常)类似于“没有端点在net.pipe上监听...”。

But the tray is running. 但是托盘正在运行。 I created a test app (console) to communicate with the tray. 我创建了一个测试应用程序(控制台)以与托盘通信。 This works fine. 这很好。 If I start this test app with psexec -I ... to run it with a local system account it is also running. 如果我使用psexec -I ...启动此测试应用程序,以使用本地系统帐户运行该应用程序,则该应用程序也正在运行。 I have no idea about possible reasons and so I have two questions: 我不知道可能的原因,所以有两个问题:

  1. is it "allowed" to host a wcf service in a tray app (running in user context) and call it by a process running in local system account? 是否“允许”在托盘应用程序中托管wcf服务(在用户上下文中运行)并由在本地系统帐户中运行的进程调用它?
  2. if yes, is there a possible policy/security setting which can prevent this functionality? 如果是,是否有可能阻止该功能的策略/安全设置?

The only workaround I could think off is to create a helper service which I can use as some kind of a broker (connect from tray with a callback interface which could be used by the other process). 我唯一可以考虑的解决方法是创建一个可以用作某种代理的帮手服务(通过托盘与回调接口连接,该接口可以供其他进程使用)。 But this seems to be a big overhead... 但这似乎是很大的开销...

The answer is, it is not possible. 答案是,这是不可能的。

The reason is explained here: Connecting via named pipe from windows service (session#0) to desktop app (session #1) 原因在这里进行了解释: 通过命名管道从Windows服务(会话#0)连接到桌面应用程序(会话#1)

It looks like my test was successful, because psexec was still running in session #1. 看来我的测试成功了,因为psexec仍在会话#1中运行。 My implementation is now using the already above described workaround 我的实现现在正在使用上述解决方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM