简体   繁体   English

主机C#winforms在VB6应用程序中

[英]Host C# winforms in VB6 applications

I have a VB 6 application and we are starting to port it over to C#. 我有一个VB 6应用程序,我们开始将它移植到C#。 We have finished one of the screens and wanted to see if there was an incremental way of hosting the winform within VB to start to have the existing users get used to new screens. 我们已经完成了其中一个屏幕,并想看看是否有一种增量方式在VB中托管winform以开始让现有用户习惯新屏幕。 This is a migration strategy.. 这是一个迁移策略..

Any thoughts. 有什么想法吗。

The Interop Forms Toolkit allows you to create .NET Forms and User Controls that can be used in VB 6.0 applications. Interop Forms Toolkit允许您创建可在VB 6.0应用程序中使用的.NET窗体和用户控件。 This allows you to migrate VB 6.0 applications to .NET over time (a form or part of a form at a time). 这允许您随着时间的推移将VB 6.0应用程序迁移到.NET(一次一个表单或表单的一部分)。 However, the toolkit relies on features from the Microsoft.VisualBasic assembly and the VB.NET compiler so it doesn't work with C#. 但是,该工具包依赖于Microsoft.VisualBasic程序集和VB.NET编译器的功能,因此它不适用于C#。

There are a couple articles/samples on CodeProject.com that discuss the toolkit and how to use it with C#. CodeProject.com上有几篇文章/样本讨论了工具包以及如何在C#中使用它。

Interop Forms Toolkit 2.0 Tutorial Interop Forms Toolkit 2.0教程

VB6 - C# Interop Form Toolkit VB6 - C#Interop Form Toolkit

Beth Massi has several articles and webcasts on the use of the Toolkit you can use for reference. Beth Massi有几篇关于使用Toolkit的文章和网络广播,您可以参考这些文章和网络广播。 Check out her blog for links to resources. 查看她的博客 ,获取资源链接。

Have you looked at this? 看过这个吗? Direct Link to Product here 此处直接链接到产品

You do not need any third party tools out anything outside of what comes with Visual Studio if you mainly just want your VB6 program to cause a .NET Winform to be displayed. 如果您只是希望VB6程序能够显示.NET Winform,那么除了Visual Studio之外的任何东西都不需要任何第三方工具。

The approach we have taken here is to expose a C# wrapper class to VB6 by giving it a COM interface. 我们在这里采用的方法是通过给它一个COM接口将一个C#包装类暴露给VB6。 This class has a few methods which can be called from VB6. 这个类有一些可以从VB6调用的方法。 They, in turn, instantiate and then show the Winform. 然后,它们实例化然后显示Winform。 It works well. 它运作良好。

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

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