PRB: Name Collision in the ActiveX Wrapper Class (325618)
The information in this article applies to:
- Microsoft .NET Framework 1.0
- Microsoft Windows .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 "More Information" section of this article. STATUSThis
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: 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- Create a new Visual C# .NET Windows Application project. By
default, Form1.cs is created.
- On the Tools menu, click Customize Toolbox.
- In the Customize Toolbox dialog box, click the COM Components tab, click to select Microsoft Web Browser control (shdocvw.dll), and then click OK.
- Add the Explorer control to Form1. A private variable axWebBrowser1 of type AxSHDocVw.AxWebBrowser is added to the Form1 class.
- 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.
Modification Type: | Minor | Last Reviewed: | 5/28/2003 |
---|
Keywords: | kbprb KB325618 |
---|
|