문제

com-visible을 만들려고하는 다음 인터페이스가 있습니다. 유형-자기를 생성하려고 할 때 구현 클래스가 일반 등급에서 파생된다는 사실이 마음에 들지 않습니다.

일반 클래스를 COM 구현 클래스로 사용할 수 있습니까? (나는 비 게 니체 래퍼를 쓸 수 있고 com으로 내보낼 수 있다는 것을 알고 있지만, 이것은 오히려 할 또 다른 레이어를 추가합니다.)

[ComVisible(true)]
public interface IMyClass
{
   ...
}

[ComVisible(true), ComDefaultInterface(typeof(IMyClass))]
[ClassInterface(ClassInterfaceType.None)]
public class MyClass : BaseClass<IMyClass>, IMyClass
{
   ...
} 

에러 메시지:

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.
도움이 되었습니까?

해결책

일반 유형에서 파생 된 일반 유형 및 유형은 내보낼 수 없습니다. 세트 ComVisible(false) 너의 MyClass 유형. 비 게 릭 클래스 구현을 만들거나 인터페이스 만 사용해야합니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top