Microsoft KB Archive/317346

= INFO: Native Versus COM-Callable .NET Controls in Internet Explorer =

Article ID: 317346

Article Last Modified on 2/23/2007

-

APPLIES TO


 * Microsoft .NET Framework 1.1
 * Microsoft .NET Framework 1.0
 * Microsoft Internet Explorer 5.01
 * Microsoft Internet Explorer 5.5
 * Microsoft Internet Explorer (Programming) 6.0

-



This article was previously published under Q317346



SUMMARY
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.



MORE INFORMATION
Most developers prefer to host a .NET UserControl by using the overloaded syntax for the OBJECT tag, as follows  where &quot;Assembly.dll&quot; is a relative, virtual, or absolute path to the .NET assembly that contains your control, and &quot;Full.Namespace.ControlName&quot; 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.

