Article ID: 325618 - Last Review: February 23, 2007 - Revision: 3.3 PRB: Name Collision in the ActiveX Wrapper ClassThis article was previously published under Q325618 On This PageSYMPTOMS 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: AxHost Class Members
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsaxhostmemberstopic.asp)
NOTE: The wrapper class that is mentioned earlier is derived from the AxHost class. Event Name CollisionIf 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
| Article Translations
|

Back to the top
