Windows 服务/进程 - 交换数据/指令

发布于 2024-09-17 00:35:41 字数 231 浏览 3 评论 0原文

我需要一种在进程和 Windows 服务之间交换数据的方法。 该进程(Windows 窗体应用程序、控制台应用程序,将来还有 Web 解决方案)需要指示 Windows 服务并与之交互。 我想知道哪种方法是实现这一目标的最佳方法。 我将用 C# 编写解决方案,.NET Framework 版本并不重要。 过去我使用过远程处理(Activator)、带有契约的 WCF 接口、进程间交换 IPC 和一些命名管道实现。你的经验是什么?其他方式?

I need a way to exchange data between a process and a windows service.
The process (Windows Form Application, Console Application, in the future also a Web Solution) needs to instruct and interact with the windows service.
I want to know which way is the best to accompplish this.
I'll write the solution in C#, .NET Framework version does not matter.
In the past I've used Remoting (Activator), WCF Interface with Contracts, Inter Process Exchange IPC and some named pipe implementation. What is your experience? Other ways?

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

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

发布评论

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

评论(2

救星 2024-09-24 00:35:50

我以前的经验一直是通过 IPCChannel,主要是因为我必须参与的唯一代码可以进行任何形式的进程间通信。它从来没有给我带来任何问题,并且当我输入代码时,代码运行得非常愉快。

这个问题唯一真正的答案是,无论你最舒服的答案是什么。

My previous experiences have always been over an IPCChannel, mainly because the only code I've had to be involved in that does any form of inter-process communication. It's never caused me any problems and the code is working away quite merrily as I type.

The only real answer to this question is, whichever you're most comfortable with.

◇流星雨 2024-09-24 00:35:48

我会选择WCF。这是目前最现代、可能也是最受支持的方法。它在大多数情况下“取代”了旧技术。 WCF 的一个很好的功能是,如果您需要将服务转移到其他协议,您只需在配置中即可完成。

如果您希望 Windows 服务始终与其他应用程序在同一台计算机上运行,​​您可以将 WCF 与 netNamedBinding 结合使用。如果您决定将服务移至其他计算机,则必须更改配置(可能更改为 netTcpBinding),因为 WCF 中的命名管道仅限于 IPC。

I would choose WCF. It is most modern and probably best supported approach at the moment. It "replaced" older technologies in most scenarios. Nice feature of the WCF is that if you need to move your service to other protocol you can do that simply in configuration.

If you expect that windows service will always run on the same machine as other application you can use WCF with netNamedBinding. If you decide to move your service to other machine you will have to change configuration (probably to netTcpBinding) because Named pipes in WCF are limited only to IPC.

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