8

That is a followup from my previous question, but you don't need to read it to understand that one.

I'm designing an interface in .NET that would be consumed from COM applications (mainly VB6, but Visual C++ 6 is also a possibility) and I would like to use Collection types as argument and return types for the methods in the interface.

Questions:

  1. What happens to the VB6 built-in collection types (arrays, collections, dictionaries) when they go through interop? My current guess is that:

    • arrays -> System.Array
    • collections -> Microsoft.VisualBasic.Collection
    • dictionaries -> System.Collections.Hashtable

    Is that correct?

  2. Which interfaces should I use as return types? IEnumerable, ICollection, IList, IDictionary? Would I be able to do a For Each in VB6 to iterate over these interfaces? Should I use the generic or non-generic variants of the interfaces?
Community
  • 1
  • 1
Jean Hominal
  • 16,518
  • 5
  • 56
  • 90
  • My guess would be that VB collections and dictionaries would go through COM interop and stay as VB collections and dictionaries, the same way any class would go through com interop. – Brian Jun 04 '10 at 17:09
  • You might want to see http://stackoverflow.com/questions/7003844/why-is-it-that-arraylist-works-with-com-interop-but-ilistt-doesnt and http://stackoverflow.com/questions/269581/what-are-alternatives-to-generic-collections-for-com-interop – nawfal Nov 11 '13 at 07:34

1 Answers1

1

I think this article over on Codeproject will cover most of your questions on interop

https://web.archive.org/web/20181009002630/https://www.codeproject.com/Articles/990/Understanding-Classic-COM-Interoperability-With-NE

-http://www.codeproject.com/KB/COM/cominterop.aspx

Rich Turner
  • 10,800
  • 1
  • 51
  • 68
  • 1
    Unfortunately this is not the answer to the question. I am a little bit in a hurry and have no time for reading the whole article at the moment. I would appreciate a simple and specific answer. – Dennis Kassel Sep 15 '16 at 14:59
  • 1
    The questions "What happens to the VB6 built-in collection types (arrays, collections, dictionaries) when they go through interop?" and "Which interfaces should I use as return types" are not easily answerable in anything short of a thoroughly researched and lengthy answer - a good example of which I provided a link to. Sometimes, you have to read & research and do the work. – Rich Turner Apr 26 '18 at 19:23
  • The link is bad, robbing this answer of whatever value it once had. If you are going to answer with a link, please include an excerpt which answers the question along with it. – Daniel Mar 01 '21 at 19:58