Microsoft KB Archive/315149

= BUG: Active Template Library Implement Connection Point Wizard Generates Incorrect Code =

Article ID: 315149

Article Last Modified on 4/11/2003

-

APPLIES TO


 * Microsoft Visual C++ .NET 2002 Standard Edition
 * Microsoft Visual C++ .NET 2003 Standard Edition

-



This article was previously published under Q315149



SYMPTOMS
The Active Template Library (ATL) Implement Connection Point Wizard generates incorrect code when it reimplements a connection point on an ATL COM object that supports connection points.

Each time that you choose to implement a connection point on the same source interface, the wizard adds the following line of code, where _ITestEvents is the source interface: __event __interface _ITestEvents;

NOTE: This behavior occurs only with attributed ATL projects.



RESOLUTION
To work around this problem, delete the extra line of code that ATL adds to the header file of the object.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce the Behavior
 Use the Implement Connection Point wizard to create a default ATL project, and then click Finish. Add an ATL simple object with support for connection points:  In Solution Explorer, right-click the project name, and then click Add Class. In the Add Class dialog box, click to expand the node under Categories, and then click ATL. In the right pane, under Templates, click ATL Simple Object. Type a name (for example, Test) in the Short name box.</li> In the left pane, click Options, select the Connection points check box, and then click Finish.</li></ol> </li> In Solution Explorer, switch to the Class View, right-click the objects class CTest, and then click Add Connection Point.</li> Select the project's dispinterface, _ITestEvents (for which a connection point is already present), click the > box, and then click Finish.</li>  Open the header file, Test.h, for the object that you added earlier, and note that the wizard has generated an additional line of code as follows: __event __interface _ITestEvents; </li> Build the project; you receive the following errors:

Test.h(66) : warning C4921: 'source': attribute value '_ITestEvents' should not be multiply specified

Test.h(66) : error C2500: 'CTest' : 'ATL::IConnectionPointImpl<T,piid,CDV>' is already a direct base class with [           T=CTest, piid=& _GUID_ed85b6e7_9f61_40f0_9ce0_46cd76428282, CDV=ATL::CComDynamicUnkArray ]

</li> To resolve the error, remove the line of code that is described in step 5.</li> Build the project again; you receive no errors.</li></ol>

<div class="references_section">