Interop Forms Toolkit
InteropUserControlsOverview

Interop UserControls are Windows Forms controls created in Visual Basic .NET that can be used on Visual Basic 6.0 forms. They allow you to add .NET functionality to a Visual Basic 6.0 application without the need for an Interop form. In Multiple Document Interface (MDI) applications Interop UserControls can be placed directly on a Visual Basic 6.0 MDI child form, solving the limitation of not being able to use Interop forms as an MDI child.

Interop UserControls are created in Visual Basic .NET by using a VB6 Interop UserControl project template, essentially a Windows Control project that includes code to marshal common properties, define some common Visual Basic 6.0 methods, and automatically register the control for COM interop. When the control is built in Visual Studio .NET it is registered; you can then add it to the Visual Basic 6.0 toolbox and use it like any Visual Basic 6.0 control.

The Interop UserControl provides full Intellisense support when used in Visual Basic 6.0. As with Interop Forms, if you reference the Interop Forms Toolkit you can also raise application-level events and access globals via the InteropToolbox and InteropGlobals classes.

Ensuring Binary Compatibility

In order to avoid breaking changes and ensure binary compatibility between different versions, the following practices are recommended:

a) Ensure that all new public methods/properties/events are added at the bottom of the class.

b) Avoid changing the names of assemblies or the class names of Interop UserControls/InteropForms.

c) When specifying a new member with the same name as a member in the base class, you must use either the Shadows or Overrides keyword.

d) You must make sure that any data types can be marshalled correctly.

Custom events can also be added and raised using the RaiseEvent keyword. In order to handle the events in Visual Basic 6.0, you must add a second reference and declare a WithEvents object. For more information, see How To: Handle Interop UserControl Events.

You can also create a control library containing multiple Interop UserControls, creating additional controls in your Visual Basic Interop UserControl project by using the VB6 Interop UserControl item template.

Interop UserControl limitations

Interop UserControls are .NET controls, and as such there are a few limitations when using them in Visual Basic 6.0.

For More Information

The following topics provide more information about creating and using Interop UserControls.

How To: Create an Interop UserControl

How To: Handle Interop UserControl Events

How To: Debug a Hybrid Application

How To: Deploy A Hybrid Application

Walkthrough: Creating and Consuming an Interop UserControl