ProxyGen has an inheritance issue with COM hosts.

Q:

When working with a COM host, such as the ShapeAppMFC sample included in the SDK, ProxyGen creates descriptor and proxy files which do not expose events due to the inheritance structure.  Three types are generated for a class: the classType, IClassType, and _IClassTypeEvents.  The classType implements both IClassType and _IClassTypeEvents.  IClassType is the type passed between the proxy and host; however, IClassType does not implement _IClassTypeEvents- therefore the events are not accessible to VSTA add-ins. How can I make them accessible?

 

 

A:

 

With COM hosts, descriptor or proxy files must be manually modified to add the inheritance of the _IClassTypeEvents to the IClassType to expose events to VSTA add-ins.

(Also see this blog post)

Included in AutoProxyGen is a VSTA addin AutoProxyGen_ShapeAppMFC_InheritenceFix that can help you with this, or you can follow these steps:

1)      Add the inheritance of the _IDrawingEvents to the IDrawing type in the proxy

Alternative:  Use ProxyGen to create the descriptor file and add the inheritance of the _IDrawingEvents to the IDrawing type prior to using ProxyGen to create the proxy file.

2)      Rebuild the sample host.

You can now hook into an event of the active drawing because the events are exposed through the IDrawing type.

  

 

Proxy file w/ inheritance added:

 

Alternative- descriptor file w/ inheritance added:

 

 

Sample add-in w/ events for drawing accessible:

 

 

 

 


Posted Jun 22 2009, 11:05 AM by BillL
Copyright Summit Software Company, 2008. All rights reserved.