Microsoft KB Archive/325618

= PRB: Name Collision in the ActiveX Wrapper Class =

Article ID: 325618

Article Last Modified on 2/23/2007

-

APPLIES TO


 * Microsoft .NET Framework 1.0
 * Microsoft .NET Framework 1.1

-



This article was previously published under Q325618



SYMPTOMS
When you use a property or a method of an ActiveX wrapper class for an ActiveX control, the property or method does not work as you expect. You also see method and property names that are prefixed with Ctl, and you see event names that are appended with Event in the ActiveX wrapper class.



CAUSE
This occurs because of a name collision. Name collisions occur when the ActiveX wrapper class that is generated by the Windows Forms ActiveX Control Importer tool (aximp.exe) includes a property, method, or event that has the same name as an ActiveX control. For example, the Refresh method of the ActiveX control conflicts with the Refresh method that the ActiveX wrapper class adds to the control. To manage this type of conflict, the ActiveX wrapper class renames the ActiveX control method to CtlRefresh. If you must call the Refresh method of the ActiveX control, call CtlRefresh.



RESOLUTION
Call the appropriate property, method, or event that is explained in the &quot;More Information&quot; section of this article.



STATUS
This behavior is by design.



MORE INFORMATION
For Windows Forms to work with an ActiveX control, additional properties, methods, and events are added to the control. For example, properties such as Size, and Visible become extended properties of your control. These additional properties, methods, and events, together with the public properties, methods, and events of the ActiveX control, form the new wrapper class. When you write code against the control, you are writing the code against the wrapper class. The wrapper class delegates to the ActiveX control. If you set a public property that is available on the ActiveX control, the wrapper class passes the property setting through to the control. If you set an extended property that is not found on the ActiveX control, the wrapper class performs the operation on the control, such as toggling visibility, or changing its size.

For more information about these extended properties, methods and events, visit the following Microsoft Web site:

AxHost Class Members

NOTE: The wrapper class that is mentioned earlier is derived from the AxHost class.

Event Name Collision
If an event name conflicts with another property or base class event name, the wrapper class renames the event by appending the word Event to the end of the event name. An example of an event name collision is the Microsoft WinSock control. If you put a WinSock control on a Windows form and view its events, you see that the Close and Connect events have been renamed to CloseEvent and ConnectEvent, respectively.

Steps to Reproduce the Behavior

 * 1) Create a new Visual C# .NET Windows Application project. By default, Form1.cs is created.
 * 2) On the Tools menu, click Customize Toolbox.
 * 3) In the Customize Toolbox dialog box, click the COM Components tab, click to select Microsoft Web Browser control (shdocvw.dll), and then click OK.
 * 4) Add the Explorer control to Form1. A private variable axWebBrowser1 of type AxSHDocVw.AxWebBrowser is added to the Form1 class.
 * 5) Program the Web Browser control using axWebBrowser1. When you type axWebBrowser1, and then type a period, IntelliSense displays all the properties, methods, and events for the Web Browser wrapper class. You see both a Refresh method, and a CtlRefresh method. If you want to call the Refresh method of the ActiveX control, you must call CtlRefresh.

NOTE: You will also see other properties with conflicting names that are prefixed with Ctl for the Web Browser control.

Keywords: kbprb KB325618

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.