简体   繁体   English

自定义RPC,WCF和.NET远程处理

[英]Custom RPC vs WCF vs .NET Remoting

I have written a simple RPC class that lets me serialize and send binary data between a .net desktop app and a .net server app. 我编写了一个简单的RPC类,使我可以在.net桌面应用程序和.net服务器应用程序之间进行序列化和发送二进制数据。 In a nutshell, a client could send: 简而言之,客户可以发送:

Dim Message as new TCPMessage
Message.Handler = "NewUser"
Message.AddField("FirstName", "Paul")
Message.AddField("Photo", PhotoBytes)
Message.Send()

And the server would reconstruct the data on the other end: 服务器将在另一端重建数据:

Public Sub NewUser (Message As TCPMessage)
    Dim FirstName as string = Message.GetString("FirstName")
    Dim Photo() as Bytes = Message.GetBytes("Photo")
    ...
End Sub

This all works OK for what I'm doing at the moment – it seems pretty lightweight and performant. 所有这些对于我目前正在执行的操作都是可以的-看起来很轻巧,性能也很好。

What I would like to know is, what are the pros/cons of doing this instead through .NET Remoting / WCF? 我想知道的是,通过.NET Remoting / WCF进行此操作的优点/缺点是什么? I don't know much about these technologies, however it would appear that they are a lot more flexible, with the possibility that they may also be less performant and present a considerable learning curve. 我对这些技术了解不多,但是它们似乎更加灵活,它们的性能可能会降低,并可能会带来很大的学习难度。

On the criteria of performance, learning curve, and bearing in mind that no one else will be maintaining the code, should I continue to build small internal apps using my DIY scheme, or ditch it ASAP for Remoting/WCF? 根据性能,学习曲线的标准,并牢记没有其他人会维护代码,我应该继续使用自己的DIY方案继续构建小型内部应用程序,还是尽快放弃它以用于Remoting / WCF?

Edit: Performance is key, the client apps will regularly be receiving datasets of ~200,000 rows (yes, it's absolutely necessary to receive this much data). 编辑:性能是关键,客户端应用程序将定期接收约200,000行的数据集(是的,绝对需要接收这么多的数据)。 This is all running on LAN only. 这些都仅在LAN上运行。

First off, .Net Remoting is now deprecated in favour of WCF, see Does WCF really replace .NET Remoting? 首先,现在不赞成使用.Net Remoting来支持WCF,请参阅WCF是否真的取代了.NET Remoting?

WCF is fast and relatively lightweight. WCF快速且相对轻量。 The key benefit of WCF though is that it is so configurable. WCF的主要好处是它是如此可配置的。 Making pretty much only configuration changes, you can change serilaization format, transport protocol, authentication mechanism, QOS functionality (reliability/security/scalability). 仅需进行配置更改,就可以更改序列化格式,传输协议,身份验证机制,QOS功能(可靠性/安全性/可伸缩性)。 Its also extensible enough that if it doesn't provide what you need you can add it yourself. 它还具有足够的可扩展性,如果它不能提供您所需的内容,则可以自己添加。 Finally it abstracts application code from communication code. 最后,它从通信代码中提取应用程序代码。

I'd definately use WCF for new projects. 我一定会将WCF用于新项目。 Would I change an existing application from a stable, performant, custom built solution? 我会从稳定,高性能,定制的解决方案中更改现有应用程序吗? That depends on the extent of the change, the drawbacks of the existing solution and the potential benefits wcf could bring. 这取决于更改的程度,现有解决方案的缺点以及wcf可能带来的潜在好处。

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

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