Article ID: 317346 - View products that this article applies to.
This article was previously published under Q317346
Instances of the .NET UserControl class -- .NET classes that are subclasses of the System.Windows.Forms.UserControl class -- can be hosted in Microsoft Internet Explorer 5.01-and-later in two different ways: directly through the .NET Runtime, or indirectly, as COM interop objects. Which approach you take depends on the needs of your application.
Most developers prefer to host a .NET UserControl by using the overloaded syntax for the OBJECT tag, as follows
where "Assembly.dll" is a relative, virtual, or absolute path to the .NET assembly that contains your control, and "Full.Namespace.ControlName" is a fully-qualified namespace reference to the control that you want to host.
This usage is very powerful, because .NET assemblies install by using the new zero-impact Fusion technology, which enables assembly installation without the need to write any secondary information to the user's registry. To update the control is as simple as downloading a new copy (which the Runtime takes care of automatically); removing it from the computer is as simple as removing the assembly from the Fusion download cache.
However, because of security concerns, this usage has an important limitation: You can load only controls hosted on a Web server. Any attempt to load a UserControl in Internet Explorer from the file system or the global assembly cache will be unsuccessful. This can hinder you if your application runs locally from a CD-ROM or the user's hard disk, or if business requirements dictate that the controls that you want to use be placed in the global assembly cache.
In such cases, you can compile your control to support COM interop, and host it within Internet Explorer as if it were a classic ActiveX control. This requires you to assign a globally unique identifier (GUID) to each COM-callable object by using the GuidGen.exe utility and the GuidAttribute metadata attribute defined in the .NET Framework. After that, you can use the Microsoft Windows Installer (MSI) to install your assembly on the user's target computer and register it as a COM object.
For more information about how to prepare your assemblies for interop, visit the following Microsoft Developer Network (MSDN) Web sites:
Example COM Class (C#)Note Interop hosting of .NET UserControl members is supported in Internet Explorer but not in other earlier version (legacy) COM containers.
Walkthrough: Creating COM Objects with Visual Basic .NET
For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
(http://support.microsoft.com/kb/311334/EN-US/ )INFO: ActiveX Control Containers That Support .NET Controls
Article ID: 317346 - Last Review: February 23, 2007 - Revision: 5.3