Exposing String Dictionary to COM

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve Long

    #1

    Exposing String Dictionary to COM

    Hello,
    I'm trying to expose a string dictionary to a COM client (VB6) and I'm
    having some trouble with the Keys property of the StringDictionar y.
    My class is laid out as such:
    The problem is that when I hit the Keys property VB6 says that the object
    doesn support the method or property. Help???

    <ClassInterface (ClassInterface Type.AutoDual),
    Guid("F04A8EDA-C857-4dec-BFCA-A41744CAB48B")> _
    Public Class Dictionary
    Inherits StringDictionar y

    Public Sub New()
    MyBase.New()
    End Sub

    Public Overrides Sub Add(<MarshalAs( UnmanagedType.B Str)> ByVal key As
    String, _
    <MarshalAs(Unma nagedType.BStr) >
    ByVal item As String)
    MyBase.Add(key, item)
    End Sub

    Public Overrides Sub Remove(<Marshal As(UnmanagedTyp e.BStr)> ByVal key As
    String)
    MyBase.Remove(k ey)
    End Sub

    Public Overrides ReadOnly Property Keys() As
    (<MarshalAs(Unm anagedType.BStr )> String()
    Get
    Dim s(MyBase.Count - 1) As String
    MyBase.Keys.Cop yTo(s, 0)
    Return s
    End Get
    End Property

    .... Other implementation omitted for brevity
    End Class


  • Steve Long

    #2
    Re: Exposing String Dictionary to COM

    Never mind,
    I switched from inheritance to containment and it works better now.


    "Steve Long" <Steve_Noneya@N oSpam.com> wrote in message
    news:u5c7dC6cGH A.1260@TK2MSFTN GP05.phx.gbl...[color=blue]
    > Hello,
    > I'm trying to expose a string dictionary to a COM client (VB6) and I'm
    > having some trouble with the Keys property of the StringDictionar y.
    > My class is laid out as such:
    > The problem is that when I hit the Keys property VB6 says that the object
    > doesn support the method or property. Help???
    >
    > <ClassInterface (ClassInterface Type.AutoDual),
    > Guid("F04A8EDA-C857-4dec-BFCA-A41744CAB48B")> _
    > Public Class Dictionary
    > Inherits StringDictionar y
    >
    > Public Sub New()
    > MyBase.New()
    > End Sub
    >
    > Public Overrides Sub Add(<MarshalAs( UnmanagedType.B Str)> ByVal key As
    > String, _
    >[/color]
    <MarshalAs(Unma nagedType.BStr) >[color=blue]
    > ByVal item As String)
    > MyBase.Add(key, item)
    > End Sub
    >
    > Public Overrides Sub Remove(<Marshal As(UnmanagedTyp e.BStr)> ByVal key[/color]
    As[color=blue]
    > String)
    > MyBase.Remove(k ey)
    > End Sub
    >
    > Public Overrides ReadOnly Property Keys() As
    > (<MarshalAs(Unm anagedType.BStr )> String()
    > Get
    > Dim s(MyBase.Count - 1) As String
    > MyBase.Keys.Cop yTo(s, 0)
    > Return s
    > End Get
    > End Property
    >
    > .... Other implementation omitted for brevity
    > End Class
    >
    >[/color]


    Comment

    Working...