Visual C++ Developer Center > Visual C++ Forums > Visual C++ Language > KB948986: VS 2005:error C2011: 'ICOMAdminCatalog' : 'struct' type redefinition
Ask a questionAsk a question
 

AnswerKB948986: VS 2005:error C2011: 'ICOMAdminCatalog' : 'struct' type redefinition

  • Thursday, August 28, 2008 4:16 AMXiaoyun Li – MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    KNOWLEDGE BASE SOLUTIONS

    KNOWLEDGE BASE SOLUTIONS PROVIDE INFORMATION DIRECTLY FROM WITHIN THE MICROSOFT SUPPORT ORGANIZATION. THE INFORMATION CONTAINED HEREIN IS CREATED IN RESPONSE TO EMERGING OR UNIQUE TOPICS, OR IS INTENDED SUPPLEMENT OTHER KNOWLEDGE BASE INFORMATION.

     

    Link to Original Article from Microsoft Support

    VS 2005:error C2011: 'ICOMAdminCatalog' : 'struct' type redefinition

    Action

    Add the following code to any .cpp source file of default generated ATL DLL project and compile:
       #include <comsvcs.h>
       #import "comadmin.dll" no_namespace named_guids

    Result

    You will get the following error:
    {path to your project}\debug\comadmin.tlh(69) : error C2011: 'ICOMAdminCatalog' : 'struct' type redefinition
    C:\Program Files (x86)\Microsoft Visual Studio 8\VC\PlatformSDK\include\comadmin.h(155) : see declaration of 'ICOMAdminCatalog'

Answers

  • Thursday, August 28, 2008 4:19 AMXiaoyun Li – MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Cause

    Here the conflict is between the TLH file generated because of #import statement, and the comadmin.h header that is being #included through comsvcs.h.  The redefinition error is because all the enums and classes are generated as 'struct' in comadmin.tlh file, but comadmin.h declares them as classes.

    Resolution

    Remove 'no_namespace' from #import statement so that it generates the namespace.
    Qualify all the references being made for classes and enums with the namespace identifier. For example:
    COMAdmin::COMAdminAccessChecksApplicationLevel

    Here 'COMAdmin' is the namespace identifier and COMAdminAccessChecksApplicationLevel is an enum value declared in the type library.

    More Information

    The same issue doesn't occur in VS 6.0 since comadmin.h declares classes and enums as structs. Projects that migrate from VS 6.0 to VS 2005 may face this kind of issue.

    DISCLAIMER

    MICROSOFT AND/OR ITS SUPPLIERS MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY, RELIABILITY OR ACCURACY OF THE INFORMATION CONTAINED IN THE DOCUMENTS AND RELATED GRAPHICS PUBLISHED ON THIS WEBSITE (THE “MATERIALS”) FOR ANY PURPOSE. THE MATERIALS MAY INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS AND MAY BE REVISED AT ANY TIME WITHOUT NOTICE.

    TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, MICROSOFT AND/OR ITS SUPPLIERS DISCLAIM AND EXCLUDE ALL REPRESENTATIONS, WARRANTIES, AND CONDITIONS WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO REPRESENTATIONS, WARRANTIES, OR CONDITIONS OF TITLE, NON INFRINGEMENT, SATISFACTORY CONDITION OR QUALITY, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THE MATERIALS.

All Replies

  • Thursday, August 28, 2008 4:19 AMXiaoyun Li – MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Cause

    Here the conflict is between the TLH file generated because of #import statement, and the comadmin.h header that is being #included through comsvcs.h.  The redefinition error is because all the enums and classes are generated as 'struct' in comadmin.tlh file, but comadmin.h declares them as classes.

    Resolution

    Remove 'no_namespace' from #import statement so that it generates the namespace.
    Qualify all the references being made for classes and enums with the namespace identifier. For example:
    COMAdmin::COMAdminAccessChecksApplicationLevel

    Here 'COMAdmin' is the namespace identifier and COMAdminAccessChecksApplicationLevel is an enum value declared in the type library.

    More Information

    The same issue doesn't occur in VS 6.0 since comadmin.h declares classes and enums as structs. Projects that migrate from VS 6.0 to VS 2005 may face this kind of issue.

    DISCLAIMER

    MICROSOFT AND/OR ITS SUPPLIERS MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY, RELIABILITY OR ACCURACY OF THE INFORMATION CONTAINED IN THE DOCUMENTS AND RELATED GRAPHICS PUBLISHED ON THIS WEBSITE (THE “MATERIALS”) FOR ANY PURPOSE. THE MATERIALS MAY INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS AND MAY BE REVISED AT ANY TIME WITHOUT NOTICE.

    TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, MICROSOFT AND/OR ITS SUPPLIERS DISCLAIM AND EXCLUDE ALL REPRESENTATIONS, WARRANTIES, AND CONDITIONS WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO REPRESENTATIONS, WARRANTIES, OR CONDITIONS OF TITLE, NON INFRINGEMENT, SATISFACTORY CONDITION OR QUALITY, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THE MATERIALS.