开发者

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-g开发者_JAVA技巧eneric variants of the interfaces?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜