Microsoft KB Archive/315149

From BetaArchive Wiki

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.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Use the Implement Connection Point wizard to create a default ATL project, and then click Finish.
  2. Add an ATL simple object with support for connection points:
    1. In Solution Explorer, right-click the project name, and then click Add Class.
    2. In the Add Class dialog box, click to expand the node under Categories, and then click ATL.
    3. In the right pane, under Templates, click ATL Simple Object.
    4. Type a name (for example, Test) in the Short name box.
    5. In the left pane, click Options, select the Connection points check box, and then click Finish.
  3. In Solution Explorer, switch to the Class View, right-click the objects class CTest, and then click Add Connection Point.
  4. Select the project's dispinterface, _ITestEvents (for which a connection point is already present), click the > box, and then click Finish.
  5. 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;
                        
  6. 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
            ]
                            
  7. To resolve the error, remove the line of code that is described in step 5.
  8. Build the project again; you receive no errors.


REFERENCES

For more information, see the Microsoft online Help documentation at the following MSDN Web sites:

Keywords: kbbug kbnativeattributes kbpending kbprod2web KB315149