Recently the VB team released the Interop Forms Toolkit, which allows VB6 developers to extend their existing applications using .NET. The toolkit allows developers to write a regular Windows Form in VB.NET, click “Generate Wrapper Classes”, and then call those forms from VB6. It also provides mechanisms for firing and handling events, and sharing application state (i.e. Globals).
We’ve heard a lot of great feedback since the release. For example, we heard that a better interop story and things like the toolkit help enable more gradual migrations. We also heard that several scenarios would benefit from additional support. Based on this we’ve been planning our next steps.
Here’s a preview of the direction we’d like to head in with interop. Two of the main areas we’re looking at are:
- Interop UserControl support – this is basically the next step after the Interop Toolkit that enables .NET UserControls to be hosted in VB6 forms using interop. As you’ll see below you can leverage UserControls to enable more UI interop scenarios.
- Data Interop – looking at what we can provide to make it easier to pass data between VB6 and .NET.
You can think of UserControl support as an extension to the Interop Forms Toolkit that adds a few more flexible ways to handle UI interop. For example, UserControls allow users to add .NET UI extensions within the same form. Also, given that a UserControl can be added to any VB6 form, there is good fidelity and communication between the VB6 forms.
As a case in point, MDI form scenarios are not supported by the current Interop Forms Toolkit due to several limitations with Windows Forms interop and the VB6 IDE. MDI support has been a top request since the release. The good news is that we believe the UserControl approach enables interop with MDI forms!
We have decided to share a very early (community supported only) Interop UserControl prototype with you to validate our direction and approach. This prototype is a UserControl project template for VS 2005 that includes attributes, helper functions, configuration, and workarounds required to do basic UserControl interop scenarios. You can use it to create a UserControl with UI, methods, properties, and even events. Simply build it and then add it to your VB6 toolbox.
To install the template, please see the file attached below called InteropUserControl.zip. This is a Visual Studio 2005 template that you can try out by placing it in your “My Documents\Visual Studio 2005\Templates\ProjectTemplates\Visual Basic” folder. Again, this is only an early prototype so expect to hit some issues and use workarounds. We hope to release a more complete version of this in the future.
We’re really interested in your feedback on this approach, so please try out the template and let us know what you think!
Jonathan Aneja & Paul Yuknewicz