首页 > 解决方案 > When writing a new c# app to replace a vb6 app, what can be used to replace COM objects?

问题描述

Background:

I have an old vb6 application that I really need to get out of my life. I love coding in c# and want to make an application to replace the old vb6 application.

The vb6 app has a component app that is installed via IIS and that the main GUI vb6 app connects to for various purposes. The reason the COM app/components exist are so that everything done is coming from the same source.

Ex: I'm working remotely and need to connect to an FTP server that is only accessible from my works network. The main GUI app connects to the COM object, issues a command and then that set of components creates the FTP connection from my work network/ip (instead of my home network/ip).

Question:

In replacing this old application GUI and COM object, what is the best approach in c#? Should I still use the old Component Services that I hate so much? Or is there a newer, better way of going about this same task?

标签: c#comvb6

解决方案


使用需要 COM 的 FTP 并没有什么特别之处(当然,用 C# 编写 GUI 也不需要 COM)。

如果我这样做:

确保您通过适当的接口/模式将您的 GUI 与后端通信分开,以便您可以轻松地替换事物并且更“面向未来”您的应用程序。

编辑:

所以,你真正追求的是:我怎样才能拥有一个通过各种方式与后端对话的 GUI 前端?

因此,对此有很多答案,基本上可以归结为:不要那样做,“选择一条车道并坚持下去”,或者“使用 WCF”。

WCF(Windows Communication Framework https://docs.microsoft.com/en-us/dotnet/framework/wcf/whats-wcf)是一种后端服务器端技术,它同时支持多种通信协议,但通常允许您进行交互客户端和服务器之间。SOAP 最初是流行的选择,但它也支持远程处理(您提到过),您可以通过 DIME 发送附件,然后就像 FTP,或者您可以自己滚动并做任何您想做的事情(例如使用 Capn Proto ( https://capnproto.org/)发送二进制消息)。

或者,如果您可以摆脱尝试做所有事情,您可能想要研究 Web API 支持的 REST(https://msdn.microsoft.com/en-us/library/dn448365(v=vs. 118).aspx )。这将允许您来回发送轻量级数据,并且通常是这些天的“完成方式”。

祝你好运!


推荐阅读