Czy możliwe jest zaimplementowanie interfejsu COM z klasą generyczną .NET?
Mam następujący interfejs, który próbuję uczynić COM widocznym. Kiedy próbuję wygenerować bibliotekę typów, nie podoba mi się fakt, że moja klasa implementacji wywodzi się z klasy ogólnej.
Czy możliwe jest użycie klasy ogólnej jako klasy implementacji COM? (Wiem, że mógłbym napisać nietypowy wrapper i wyeksportować go do COM, ale to dodaje kolejną warstwę, którą wolałbym zrobić bez).
[ComVisible(true)]
public interface IMyClass
{
...
}
[ComVisible(true), ComDefaultInterface(typeof(IMyClass))]
[ClassInterface(ClassInterfaceType.None)]
public class MyClass : BaseClass<IMyClass>, IMyClass
{
...
}
Komunikat o błędzie:
Warning: Type library exporter encountered a type that derives from a generic class and is not marked as [ClassInterface(ClassInterfaceType.None)]. Class interfaces cannot be exposed for such types. Consider marking the type with [ClassInterface(ClassInterfaceType.None)] and exposing an explicit interface as the default interface to COM using the ComDefaultInterface attribute.