将通用代码(List< T>)导出到COM [英] Export generic code (List<T>)to COM
问题描述
COM不支持泛型?复制此List<T>
以便使其在tlh文件中显示为COM的最佳方法是什么?
:
c#::
COM doesn't support generics?What would be the best way to replicate this List<T>
so that it's COM visible in the tlh file.
:
c#::
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("FA677671-5E26-4307-AD2B-19BF1E7AFF8B")]
public interface IEvents
{
IEvents[] CreateListeners();
}
在我拥有的C ++中,
in C++ i have,
CComSafeArray<CSharp::IEvents> ppSA;
pInterface->CreateListeners(ppSA->GetSafeArrayPtr());
我的问题是我应该在此Create实例函数中做什么以便复制此语句 List evt = new List(); 在托管的C#中?
My question what i should do in this Create instance function so asto replicate this statement List evt=new List(); in the managed c#?
推荐答案
不正确,不支持泛型类型:
Correct, generic types are not supported:
COM模型不支持泛型类型的概念.因此,通用类型不能直接用于COM互操作.
The COM model does not support the concept of generic types. Consequently, generic types cannot be used directly for COM interop.
http://msdn.microsoft.com/en-us/library /ms229590.aspx
也许这是开始的地方:
这篇关于将通用代码(List< T>)导出到COM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!