DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    David Chu Guest

    enum type in COM


    I have an enum type in VB6.0 like this:

    Public Enum enum_search_flag
    ecSearchSubTree = 1
    ecSearchBase = 2
    ecSearchOneLevel = 3
    End Enum

    After compile by VB6.0, the enum type in idl it something like this:

    typedef [uuid(A1EE7EA8-27CF-48EF-99E1-62EC63E62ED2), version(1.0)]
    enum {
    ecSearchSubTree = 1,
    ecSearchBase = 2,
    ecSearchOneLevel = 3
    } enum_search_flag;

    I ported it to VB.Net in a class like this:

    <GuidAttribute("A1EE7EA8-27CF-48EF-99E1-62EC63E62ED2")> _
    Public Enum enum_search_flag
    ecSearchSubTree = 1
    ecSearchBase = 2
    ecSearchOneLevel = 3
    End Enum

    However the idl from the tlb created by VB.Net is different:

    typedef [uuid(A1EE7EA8-27CF-48EF-99E1-62EC63E62ED2), version(1.0)]
    enum {
    enum_search_flag_ecSearchSubTree = 1,
    enum_search_flag_ecSearchBase = 2,
    enum_search_flag_ecSearchOneLevel = 3
    } enum_search_flag;

    The difference is that "enum_search_flag_" is added to the front of each
    enumerator. How can I instruct VB.Net to create the enum like the way in
    VB6.0 (without the prefix!)?

    D. Chu

  2. #2
    Anthony Glenwright Guest

    Re: enum type in COM


    This is just a guess, but you could try:

    <GuidAttribute("A1EE7EA8-27CF-48EF-99E1-62EC63E62ED2")> _
    Public Enum enum_search_flag
    ComAliasName<"ecSearchSubTree"> ecSearchSubTree = 1
    ComAliasName<"ecSearchBase"> ecSearchBase = 2
    ComAliasName<"ecSearchOneLevel"> ecSearchOneLevel = 3
    End Enum


    But it's just a guess, I haven't used ComAliasName before. If that doesn't
    work, try looking at some of the other attributes in the System.runtime.interopServices
    namespace.

    "David Chu" <chud@hotmail.com> wrote:
    >
    >I have an enum type in VB6.0 like this:
    >
    > Public Enum enum_search_flag
    > ecSearchSubTree = 1
    > ecSearchBase = 2
    > ecSearchOneLevel = 3
    > End Enum
    >
    >After compile by VB6.0, the enum type in idl it something like this:
    >
    > typedef [uuid(A1EE7EA8-27CF-48EF-99E1-62EC63E62ED2), version(1.0)]
    > enum {
    > ecSearchSubTree = 1,
    > ecSearchBase = 2,
    > ecSearchOneLevel = 3
    > } enum_search_flag;
    >
    >I ported it to VB.Net in a class like this:
    >
    > <GuidAttribute("A1EE7EA8-27CF-48EF-99E1-62EC63E62ED2")> _
    > Public Enum enum_search_flag
    > ecSearchSubTree = 1
    > ecSearchBase = 2
    > ecSearchOneLevel = 3
    > End Enum
    >
    >However the idl from the tlb created by VB.Net is different:
    >
    > typedef [uuid(A1EE7EA8-27CF-48EF-99E1-62EC63E62ED2), version(1.0)]
    > enum {
    > enum_search_flag_ecSearchSubTree = 1,
    > enum_search_flag_ecSearchBase = 2,
    > enum_search_flag_ecSearchOneLevel = 3
    > } enum_search_flag;
    >
    >The difference is that "enum_search_flag_" is added to the front of each
    >enumerator. How can I instruct VB.Net to create the enum like the way in
    >VB6.0 (without the prefix!)?
    >
    >D. Chu



  3. #3
    David Chu Guest

    Re: enum type in COM


    I tried this method, but the prefix is still there. ComAliasName looks like
    to define an aliase type.

    I tried to search from System.runtime.interopServices. However, I have no
    luck to find one. Does anyone know there is a way to disable this type prefix
    behaviour when creating tlb file? Thanks for any help!

    D. Chu

    "Anthony Glenwright" <anthony.glenwright@inventua.com> wrote:
    >
    >This is just a guess, but you could try:
    >
    ><GuidAttribute("A1EE7EA8-27CF-48EF-99E1-62EC63E62ED2")> _
    > Public Enum enum_search_flag
    > ComAliasName<"ecSearchSubTree"> ecSearchSubTree = 1
    > ComAliasName<"ecSearchBase"> ecSearchBase = 2
    > ComAliasName<"ecSearchOneLevel"> ecSearchOneLevel = 3
    > End Enum
    >
    >
    >But it's just a guess, I haven't used ComAliasName before. If that doesn't
    >work, try looking at some of the other attributes in the System.runtime.interopServices
    >namespace.
    >



  4. #4
    Patrick Steele [MVP] Guest

    Re: enum type in COM

    In article <3eccf15d$1@tnews.web.devx.com>, chud@hotmail.com says...
    > I tried this method, but the prefix is still there. ComAliasName looks like
    > to define an aliase type.
    >
    > I tried to search from System.runtime.interopServices. However, I have no
    > luck to find one. Does anyone know there is a way to disable this type prefix
    > behaviour when creating tlb file? Thanks for any help!


    It seems this is "by design":

    http://tinyurl.com/cera

    --
    Patrick Steele
    Microsoft .NET MVP
    http://radio.weblogs.com/0110109

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links