What is the best choice for .NET inter-process com

2018-12-31 09:02发布

Should I use Named Pipes, or .NET Remoting to communicate with a running process on my machine?

8条回答
忆尘夕之涩
2楼-- · 2018-12-31 09:42

If you are using the .NET Framework 3.0 or above, I would use WCF. Using WCF, you can use different bindings depeneding on the trade-off between performance/interop/etc. that you need.

If performance isn't critical and you need interop with other Web Service technologies, you will want to use the WS-HTTP binding. For your case, you can use WCF with either a net-tcp binding, or a named-pipe binding. Either should work.

My personal take is that the WCF approach is more clean as you can do Contract-Driven services and focus on messages, not objects (I'm making a generalization here based on the default programming models of WCF/.NET Remoting). I don't like sending objects across the wire because a lot of semantic information gets lost or is not clear. When all you are doing is sending a message like you are with WCF, it becomes easier to separate your concerns between communication and the classes/infrastructure that a single node is composed of.

查看更多
皆成旧梦
3楼-- · 2018-12-31 09:55

If it's on a single machine, Named Pipes gives you better performance and can be implemented with the remoting infrastructure as well as WCF. Or you can just directly use System.IO.Pipes.

查看更多
听够珍惜
4楼-- · 2018-12-31 09:56

If you mean inter-process communication, I used .NET Remoting without any problem so far. If the two processes are on the same machine, the communication is quite fast.

Named Pipes are definitely more efficient, but they require the design of at least a basic application protocol, which might not be feasible. Remoting allows you to invoke remote methods with ease .

查看更多
像晚风撩人
5楼-- · 2018-12-31 09:59

.net remoting is built into .net to do inner process communication. If you use that, they will continue to support and possibly enhance it in future versions. Named pipes doesn't give you the promise of enhancements in future versions of .net

查看更多
骚的不知所云
6楼-- · 2018-12-31 10:00

.Net remoting isn't a protocol in and of itself. It lets you pick which protocal to use: SOAP, named-pipes, etc.

查看更多
残风、尘缘若梦
7楼-- · 2018-12-31 10:01

Remoting in .NET Framework 2.0 provides the IPC channel for inter-process communication within the same machine.

查看更多
登录 后发表回答