.NET Remoting 真的已经过时了吗?

大家都在说。NET Remoting 正在被 WCF 所取代,但是我想知道这是否准确。我还没有看到任何关于 Remoting 正在被弃用的官方说法,而且在我看来,在某些情况下,Remoting 比 WCF 更有意义。没有一个 Remoting 相关的对象或方法被弃用,即使在框架的4.0版本中也是如此。这也是我的理解,系统。3.5和4.0框架中的 AddIn 使用 Remoting。

有人有相反的官方说法吗?

在这篇文章 在.NET 中选择通信选项(对于3.0来说,这是这篇文章的最新版本)中写道:

8跨应用领域通信

如果需要支持同一进程中不同应用程序域中的对象之间的通信,则必须使用。NET 远程处理。

现在,这当然是不准确的,因为 WCF 当然可以用来跨应用程序域边界,但它给出了这种情况的官方建议吗?

更新: 我给 Clemens Vaster (他是 Remoting 和 WCF 的团队成员)发了这个问题:

克莱门斯,我知道你所在的团队同时拥有远程和 wcf 我有几个问题需要问你。

首先,我有一个关于远程处理是否会消失的问题。具体来说,我们有一个相当大的应用程序,它广泛地使用远程处理进行进程内跨应用程序域通信,我想知道这种远程处理的使用是否被认为是“遗留”的。如果是这样,AppDomain 将。创建实例和朋友被替换为其他东西?

这是他的回答:

远程处理是。网络框架,因此它不会消失。COM 自 Windows NT 3.5/Windows 95以来一直在 Windows 中使用,并且一直没有消失,我也不认为它会很快消失。

也就是说,对 Remoting 的开发投资非常少。WCF 是 Remoting 的继承者,取代了 COM/DCOM 的托管代码。

对于进程内,跨应用程序域通信 Remoting 是 CLR 的本机通信方式。如果您看到性能问题在短时间内输出大量数据或消息,那么您应该认真研究一下 WCF 和 NetNamedPipeBinding。

28686 次浏览

Yes. Remoting is deprecated...and it's official from Microsoft. Here's the link:

.NET Remoting

The first line in the article says in bold:

This topic is specific to a legacy technology that is retained for backward compatibility with existing applications and is not recommended for new development. Distributed applications should now be developed using the Windows Communication Foundation (WCF).

I thought the verbiage was 'deprecated' but apparently they refer to it as 'legacy'

Calling it a legacy technology is a more accurate description.

http://msdn.microsoft.com/en-us/library/72x4h507%28VS.85%29.aspx

This topic is specific to a legacy technology that is retained for backward compatibility with existing applications and is not recommended for new development. Distributed applications should now be developed using the Windows Communication Foundation (WCF).

Update: WCF doesn't distinguish between inter/intra/process/inter/intra-appdomain. If you are using single machine communication in WCF you use named pipes- using it should give good performance in virtually all realistic scenarios.

For a performance comparison of various distributed communication technologies see here.

Clemens Vasters, the Technical Lead for the Microsoft .NET Service Bus (that means both Remoting as well as WCF) talks about WCF vs. Remoting in this forum post. To summarize the post he ends up recommending WCF over Remoting.

I'm not sure if .NET 4.0 uses remoting internally but you could try sending Clemens the question... I'm sure he knows the answer.

I think that now (2015) it's quite clear even for cross application domains: https://msdn.microsoft.com/en-us/library/vstudio/ms180984(v=vs.100).aspx

Remoting Cross AppDomains This topic is specific to a legacy technology that is retained for backward compatibility with existing applications and is not recommended for new development. Distributed applications should now be developed using the Windows Communication Foundation (WCF).

Then WCF should be used for cross application domains too.

If you like to migrate to .NET Core you have to find another solution for Remoting anyway:

.NET Remoting was identified as a problematic architecture. It's used for cross-AppDomain communication, which is no longer supported. Also, Remoting requires runtime support, which is expensive to maintain. For these reasons, .NET Remoting isn't supported on .NET Core, and we don't plan on adding support for it in the future.

Source: https://learn.microsoft.com/en-us/dotnet/core/porting/libraries#remoting