473,403 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

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 StringDictionary.
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(ClassInterfaceType.AutoDual),
Guid("F04A8EDA-C857-4dec-BFCA-A41744CAB48B")> _
Public Class Dictionary
Inherits StringDictionary

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

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

Public Overrides Sub Remove(<MarshalAs(UnmanagedType.BStr)> ByVal key As
String)
MyBase.Remove(key)
End Sub

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

.... Other implementation omitted for brevity
End Class
May 10 '06 #1
1 1413
Never mind,
I switched from inheritance to containment and it works better now.
"Steve Long" <St**********@NoSpam.com> wrote in message
news:u5**************@TK2MSFTNGP05.phx.gbl...
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 StringDictionary.
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(ClassInterfaceType.AutoDual),
Guid("F04A8EDA-C857-4dec-BFCA-A41744CAB48B")> _
Public Class Dictionary
Inherits StringDictionary

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

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

Public Overrides Sub Remove(<MarshalAs(UnmanagedType.BStr)> ByVal key As String)
MyBase.Remove(key)
End Sub

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

.... Other implementation omitted for brevity
End Class

May 10 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Thomas Philips | last post by:
Consider the following simple dictionary e={1:'one', 2: 'two'} e >>>'one' However, If I attempt to print e using a formatted string print " %(1)s" %e, I get a KeyError: '1'
8
by: Bo Peng | last post by:
Dear list, I am writing a Python extension module that needs a way to expose pieces of a big C array to python. Currently, I am using NumPy like the following: PyObject* res =...
7
by: Wilson | last post by:
Hi, How do get the Dictioanry object from FiedlInfo ? my code : fieldInfo = this.GetType().GetField("dictioanry1"); ??Dictionary<string, string> dicTemp1 = (Dictionary<string,...
6
by: buzzweetman | last post by:
Many times I have a Dictionary<string, SomeTypeand need to get the list of keys out of it as a List<string>, to pass to a another method that expects a List<string>. I often do the following: ...
3
by: Rich Shepard | last post by:
I need to learn how to process a byte stream from a form reader where each pair of bytes has meaning according to lookup dictionaries, then use the values to build an array of rows inserted into a...
11
by: Peter Kirk | last post by:
Hi i have a string variable which can take one of a set of many values. Depending on the value I need to take different (but related) actions. So I have a big if/else-if construct - but what is...
35
by: Abandoned | last post by:
I want to convert a string to command.. For example i have a string: a="" I want to do this list.. How can i do ?
2
by: Assimalyst | last post by:
Hi I have a Dictionary<string, List<string>>, which i have successfully filled. My problem is I need to create a filter expression using all possible permutations of its contents. i.e. the...
2
by: Andy B | last post by:
I don't know if this is even working or not but here is the problem. I have a gridview that I databound to a dictionary<string, stringcollection: Contract StockContract = new Contract();...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.