Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which collection interface should I use in .NET for COM-interop?

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?
like image 634
Jean Hominal Avatar asked Jun 03 '10 08:06

Jean Hominal


1 Answers

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

like image 63
Rich Turner Avatar answered Nov 15 '22 04:11

Rich Turner