473,804 Members | 3,903 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
May 10 '06 #1
1 1442
Never mind,
I switched from inheritance to containment and it works better now.
"Steve Long" <St**********@N oSpam.com> wrote in message
news:u5******** ******@TK2MSFTN GP05.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 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

May 10 '06 #2

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

Similar topics

5
3023
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
3868
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 = PyArray_FromDimsAndData(1, int*dim, PyArray_DOUBLE, char*buf); Users will get a Numeric Array object and can change its values (and actually change the underlying C array).
7
8746
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, string>)fieldInfo; Thanks Wilson
6
46194
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: <BEGIN CODE> List<stringkeyNameList = new List<string>(); foreach (string keyName in this.myDictionary.Keys)
3
2523
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 sqlite3 database table. Here's the context: The OMR card reader sends a stream of 69 bytes over the serial line; the last byte is a carriage return ('\r') indicating the end of record. Three pairs (in specific positions at the beginning of the...
11
10867
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 a better way of doing this? if ("control" == commandString) { } else if ("execute" == commandString)
35
4939
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
5902
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 dictionary essentially creates the following array: Key Value
2
3141
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(); StockContract.Dictionary = ContractDictionary<string, string>(); GridView1.DataSource=StockContract.Dictionary; So far so good. Now I assign something to the Dictionary collection through some textboxes and a button:
0
10340
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10329
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10085
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9163
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6858
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4304
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3830
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3000
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.