问题
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.
EDIT::
c#::
[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("FA677671-5E26-4307-AD2B-19BF1E7AFF8B")]
public interface IEvents
{
IEvents[] CreateListeners();
}
in C++ i have,
CComSafeArray<CSharp::IEvents> ppSA;
pInterface->CreateListeners(ppSA->GetSafeArrayPtr());
My question what i should do in this Create instance function so asto replicate this statement List evt=new List(); in the managed c#?
回答1:
Correct, generic types are not supported:
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
Perhaps this is the place to start:
C# exposing class to COM - Generic Collections
来源:https://stackoverflow.com/questions/17648004/export-generic-code-listtto-com