服务与多个用户应用程序之间的内部通信 WCF C#

发布于 2024-12-03 10:50:22 字数 718 浏览 0 评论 0原文

我目前正在开发一个 C# 项目,其中有一个作为 LocalSystem 运行的服务,以及一个为每个登录用户运行的用户应用程序(托盘应用程序)。

我需要在两者之间进行沟通。 最初,我在服务上使用 NetTcpBinding 设置了一个端点,以便客户端连接并提供其用户名。此后,客户端各自设置一个端点; net.tcp://localhost:5001/UserApp/'用户名',启用端口共享。然后,该服务可以在知道用户名的情况下连接到该端点。

不过,当我试图让程序与 UAC 良好配合时,我遇到了一些问题。启用 UAC 的端口共享要求用户在 <'allowAccounts> 中注册。 SMSvcHost.exe.config 的,即使我添加了用户,在尝试注册端点时仍然出现以下错误;

服务端点未能侦听 URI 'net.tcp://localhost:5001/UserApp/myuser' 因为访问被拒绝。 验证当前用户是否被授予适当的访问权限 SMSvcHost.exe.config 的allowAccounts 部分。

我还尝试切换到 NetNamedPipeBinding,它在托管用户应用程序时效果很好。但是,当使用此绑定时,服务无法访问客户端打开的端点。

因此,基本上我需要一种方法,让单个服务为同一台计算机上的多个用户应用程序提供端点,并且该服务能够连接到多个用户应用程序并向多个用户应用程序发送事件更新。

有什么建议吗?

I'm currently working on a project in c# where I have a service running as LocalSystem, and a user application (tray app) running for each logged on user.

I need to have communications between the two.
Initially I've set up an endpoint using NetTcpBinding on the service for the clients to connect to and supply their username. Thereafter the clients each set up an endpoint themselves as such; net.tcp://localhost:5001/UserApp/'username', with port sharing enabled. The service can then connect to that endpoint, knowing the username.

Though, when trying to get the program to work well with UAC I ran into some issues. Port sharing with UAC enabled requires the user to be registred in <'allowAccounts> of SMSvcHost.exe.config, and even though I've added the user, I still get the following errror when trying to register the endpoint;

The service endpoint failed to listen on the URI
'net.tcp://localhost:5001/UserApp/myuser' because access was denied.
Verify that the current user is granted access in the appropriate
allowAccounts section of SMSvcHost.exe.config.

I've also tried switching to NetNamedPipeBinding, which works well when hosting the user application. But when using this binding the service can not access the endpoints opened by the clients.

So, basically I need a way for a single service to provide an endpoint for multiple user applications on the same machine, and the service to be able to connect to and send event updates to multiple user applications.

Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

赠意 2024-12-10 10:50:22

在这种情况下,我会考虑使用回调通道,而不是在客户端上打开新服务(好吧 - 它几乎相同,但它很适合 WCF 框架和设置)。
您可以在此处阅读相关内容:有关单向呼叫、回调您需要了解的内容、和事件

in this case I would think about using callback channels instead of opening new services on the client (ok - it's almost the same but it fit nices into the WCF framework and setting).
You can read about this here: What you need to know about One-Way Calls, Callbacks, And Events

御弟哥哥 2024-12-10 10:50:22

您可能还想查看 Duplex 服务,特别是“wsDualHttpBinding”。它旨在满足您的要求...允许服务和客户端彼此独立地发送消息。

http://msdn.microsoft.com/en-us/library/ms731064.aspx

You may want to also look Duplex services, in particular the 'wsDualHttpBinding'. It is designed to do just want you are asking... to allow both the service and client to send messages independently to each other.

http://msdn.microsoft.com/en-us/library/ms731064.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文