c# - 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?
解决方案
使用需要 COM 的 FTP 并没有什么特别之处(当然,用 C# 编写 GUI 也不需要 COM)。
如果我这样做:
- WPF GUI(当 WinForms 消失时的未来证明......并为您提供支持 XAML 的 WinRT)。
- FTP 库中的 Nuget,如下所示: https ://www.nuget.org/packages/Ftp.dll/
确保您通过适当的接口/模式将您的 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 )。这将允许您来回发送轻量级数据,并且通常是这些天的“完成方式”。
祝你好运!
推荐阅读
- android - 华为地图不画不画
- r - 使用 h2o.gbm() 复制运行
- laravel - 如何将 $variable 从 laravel 中的同一控制器函数传递给多个视图
- java - 未找到 Maven 父依赖项
- java - Springboot 应用程序启动失败,因为 Failed to read schema document
- javascript - 为什么我们需要一个响应对象来响应 express 处理程序的某些内容?
- sql - 将带有数组的行拆分为带有子数组的多行
- c - ldd 显示 libm.so.6 但仍需要与 -lm 链接
- google-analytics-api - UserActivity 搜索 api 的权限
- terraform - Terraform 动态内部动态