在 Windows 窗体应用程序中混合使用 VB5 和 C#

发布于 2024-09-18 13:28:55 字数 88 浏览 2 评论 0原文

我想向我的应用程序添加一个窗口。是否可以使用 C#“扩展”旧的 vb5 项目?

它容易做和维护吗?这是一个好的做法吗?如果没有,还有哪些替代方案?

I'd like to add a window to my application. Is it possible to "extend" an old vb5 project using C#?

Is it easy to do and maintain and is it a good practice ? If not, what are the alternatives?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

埋情葬爱 2024-09-25 13:28:55

你想要做的事情很困难,因为你需要架起两个世界的桥梁。

VB5 和 C# 都可以创建和使用 COM 对象,您可以使用它从 .net 调用 VB5 代码或从 VB5 调用 .net 代码。

您还可以在.net 中创建和使用Active X 控件,因此如果需要,您可以以相同的形式混合VB5 和C#。

另一种选择是让两个独立的应用程序与同一个数据库通信并使用 COM(或 SendMessage)相互打开表单。

您需要深入了解 .net 才能使 COM 正常工作,但是,除非您花一些时间在 .NET 中工作,否则您不太可能有这种了解。

市场上也有一些工具声称将 VB5 代码转换为 VB.NET,但我对其中任何一个都没有厌倦。

What you are trying to do is hard as you need to bridge the two worlds.

Both VB5 and C# can create and consume COM object you can use this to call VB5 code from .net or .net code from VB5.

You can also create and use Active X controls in .net, so you can mix VB5 and C# in the same form if you must.

Another option is to have two separate applications that talk to the same database and used COM (or SendMessage) to open forms in each other.

You need a deep understand of .net to get COM working well, however you are not likely to have that understanding until you have spent some time working in .NET.

There are also tools on the market that claim to convert VB5 code into VB.NET, however I have not tired any of them.

叹梦 2024-09-25 13:28:55

编辑

我最初误读了这个问题,以为你在问 VB.NET。

您能做的最好的事情就是将 C# 公开为从 VB5 调用的 COM 对象。您只需要确保支持IDispatch

edit

I misread the question initially, thinking you were asking about VB.NET.

The best you can do is expose your C# as a COM object that you call from VB5. You just need to make sure you support IDispatch.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文