Export (0) Print
Expand All

Interoperating Using Generic Types

The COM model does not support the concept of generic types. Consequently, generic types cannot be used directly for COM interop.

The following actions are not supported and will fail with an E_NOINTERFACE error:

  • Accessing generic interfaces from COM.

  • Accessing class interfaces for nongeneric classes that derive from generic classes.

  • Generating class interfaces for generic classes. For example, the _MyGenericType interface cannot be generated for the MyGenericType<T> class.

You can access a generic class indirectly using a nongeneric base interface. For example, consider the following type:

[C#]

class MyClass <T> : IMyClass, IEnumerable<int>
{
   …
}

COM clients can make calls to instances of this type using the IMyClass interface, but calls to either _MyClass, _MyClass <T> or IEnumerable<T> will fail.

Show:
© 2014 Microsoft