我应该在 .NET 中使用哪个集合接口来实现 COM 互操作?
这是我的上一个问题的后续问题,但是你不需要阅读它来理解它。
我正在 .NET 中设计一个接口,该接口将由 COM 应用程序(主要是 VB6,但也可以使用 Visual C++ 6)使用,并且我想使用 Collection 类型作为接口中方法的参数和返回类型。
问题:
VB6 内置集合类型(数组、集合、字典)在进行互操作时会发生什么情况?我目前的猜测是:
- 数组 ->
System.Array
- 集合 ->
Microsoft.VisualBasic.Collection
- 词典 ->
System.Collections.Hashtable
这是正确的吗?
- 数组 ->
- 我应该使用哪些接口作为返回类型?
IEnumerable
、ICollection
、IList
、IDictionary
?我可以在 VB6 中执行 For Each 来迭代这些接口吗?我应该使用接口的通用还是非通用变体?
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:
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?
- arrays ->
- 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为 Codeproject 上的这篇文章将涵盖您有关互操作的大部分问题
https://web.archive.org/web/20181009002630/https://www.codeproject.com/Articles/990/Understanding-Classic-COM -与-NE的互操作性
-
http://www.codeproject.com/KB/COM/cominterop.aspxI 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