none
com visible enum behavior in vs2010 RRS feed

  • Question

  • Hi,

    In a c# project, we have the following code.

    [ComVisible(true)]
      [Guid("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")]
      public enum FunctionType
      {
        [ComVisible(false)]All = 0,
        Td = 1,
        Rd = 2
      }
    

     

    On compiling in vs2005, the enum 'all' was visible in tlb file as FunctionType_All.

    The project was ported to vs2010. While compiling in vs2010, the enum FunctionType_All is not visible in .tlb file.

    Is this  an issue withn vs2005 (or) vs2010?


    Miscrosoft Technologies Developer
    • Moved by Leo Liu - MSFT Thursday, July 14, 2011 5:10 AM Moved for better support. (From:Visual C# General)
    Tuesday, July 12, 2011 12:09 PM

Answers

  • With your description, I did a test, the result shows that VS2005 and VS2010 give different .tlb content:

     

    ------------------VS 2005-----------------------

    // Generated .IDL file (by the OLE/COM Object Viewer)

    //

    // typelib filename: <could not determine filename>

     

    [

      uuid(61BFCD1B-0153-4DBC-9836-94C6D16FEE6E),

      version(1.0),

      custom(90883F05-3D28-11D2-8F17-00A0C9A6186D, "ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")

     

    ]

    library ClassLibrary1

    {

        // TLib :     // Forward declare all types defined in this typelib

     

        typedef [uuid(20D54298-DD32-446B-86ED-84CF0D7BB68A), version(1.0)    ,

          custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, "ClassLibrary1.FunctionType")   

    ]

        enum {

            FunctionType_All = 0,

            FunctionType_Td = 1,

            FunctionType_Rd = 2

        } FunctionType;

    };

     

    ------------------VS 2010-----------------------

    // Generated .IDL file (by the OLE/COM Object Viewer)

    //

    // typelib filename: ClassLibrary1.tlb

     

    [

      uuid(62ABD801-078E-450A-B173-AD7FFB788327),

      version(1.0),

      custom(90883F05-3D28-11D2-8F17-00A0C9A6186D, "ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")

     

    ]

    library ClassLibrary1

    {

        // TLib :     // Forward declare all types defined in this typelib

     

        typedef [uuid(9320EF6D-304B-48D0-B350-4B90DCFE906D), version(1.0)    ,

          custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, "ClassLibrary1.FunctionType")   

    ]

        enum {

            FunctionType_Td = 1,

            FunctionType_Rd = 2

        } FunctionType;

    };

     

    Seems VS2005 ignores inner COMVisible attributes, in my opinion, it is an issue of VS2005, and has been fixed in VS2010.


    Eric Yang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Proposed as answer by Riquel I'm Thursday, July 21, 2011 3:54 PM
    • Marked as answer by eryang Wednesday, August 3, 2011 8:26 AM
    Friday, July 15, 2011 3:20 AM

All replies

  • Hi madhur,

    I am moving your thread into the Common Language Runtime Forum for specialized support.

    Have a nice day,

    Leo Liu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, July 14, 2011 5:11 AM
  • With your description, I did a test, the result shows that VS2005 and VS2010 give different .tlb content:

     

    ------------------VS 2005-----------------------

    // Generated .IDL file (by the OLE/COM Object Viewer)

    //

    // typelib filename: <could not determine filename>

     

    [

      uuid(61BFCD1B-0153-4DBC-9836-94C6D16FEE6E),

      version(1.0),

      custom(90883F05-3D28-11D2-8F17-00A0C9A6186D, "ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")

     

    ]

    library ClassLibrary1

    {

        // TLib :     // Forward declare all types defined in this typelib

     

        typedef [uuid(20D54298-DD32-446B-86ED-84CF0D7BB68A), version(1.0)    ,

          custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, "ClassLibrary1.FunctionType")   

    ]

        enum {

            FunctionType_All = 0,

            FunctionType_Td = 1,

            FunctionType_Rd = 2

        } FunctionType;

    };

     

    ------------------VS 2010-----------------------

    // Generated .IDL file (by the OLE/COM Object Viewer)

    //

    // typelib filename: ClassLibrary1.tlb

     

    [

      uuid(62ABD801-078E-450A-B173-AD7FFB788327),

      version(1.0),

      custom(90883F05-3D28-11D2-8F17-00A0C9A6186D, "ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")

     

    ]

    library ClassLibrary1

    {

        // TLib :     // Forward declare all types defined in this typelib

     

        typedef [uuid(9320EF6D-304B-48D0-B350-4B90DCFE906D), version(1.0)    ,

          custom(0F21F359-AB84-41E8-9A78-36D110E6D2F9, "ClassLibrary1.FunctionType")   

    ]

        enum {

            FunctionType_Td = 1,

            FunctionType_Rd = 2

        } FunctionType;

    };

     

    Seems VS2005 ignores inner COMVisible attributes, in my opinion, it is an issue of VS2005, and has been fixed in VS2010.


    Eric Yang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Proposed as answer by Riquel I'm Thursday, July 21, 2011 3:54 PM
    • Marked as answer by eryang Wednesday, August 3, 2011 8:26 AM
    Friday, July 15, 2011 3:20 AM