ComEventInterfaceAttribute 类

定义

注意

ComEventInterfaceAttribute may be unavailable in future releases.

标识源接口和实现事件接口方法的类,事件接口在从 COM 类型库中导入组件类时生成。

public ref class ComEventInterfaceAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Interface, Inherited=false)]
[System.Obsolete("ComEventInterfaceAttribute may be unavailable in future releases.")]
public sealed class ComEventInterfaceAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Interface, Inherited=false)]
public sealed class ComEventInterfaceAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Interface, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class ComEventInterfaceAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Interface, Inherited=false)>]
[<System.Obsolete("ComEventInterfaceAttribute may be unavailable in future releases.")>]
type ComEventInterfaceAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Interface, Inherited=false)>]
type ComEventInterfaceAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Interface, Inherited=false)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type ComEventInterfaceAttribute = class
    inherit Attribute
Public NotInheritable Class ComEventInterfaceAttribute
Inherits Attribute
继承
ComEventInterfaceAttribute
属性

注解

可以将此属性应用于接口,尽管 Tlbimp.exe (类型库导入程序) 在导入类型库时通常会为你应用它。

从类型库导入源接口时,它实现的任何方法都作为事件添加到生成的事件接口。 Tlbimp.exe适用于 ComEventInterfaceAttribute 事件接口,用于标识实现事件接口的方法并实现原始源接口的托管类。 公共语言运行时在运行时使用此属性来执行以下任务:

  • 将接口公开的事件与事件提供程序类中的实现相关联。

  • 将事件链接到原始 COM 源接口。

很少应用此属性。 但是,如果计划编写生成元数据的源代码,以密切模拟Tlbimp.exe生成的元数据,则应为每个原始源接口创建事件接口。 有关如何Tlbimp.exe导入事件的详细说明,请参阅 导入的成员转换。 有关如何向 .NET 客户端公开 COM 事件的说明,请参阅 如何:处理 COM 源引发的事件

构造函数

ComEventInterfaceAttribute(Type, Type)

用源接口和事件提供程序类初始化 ComEventInterfaceAttribute 类的新实例。

属性

EventProvider

获取实现事件接口方法的类。

SourceInterface

从类型库获取原始源接口。

TypeId

在派生类中实现时,获取此 Attribute 的唯一标识符。

(继承自 Attribute)

方法

Equals(Object)

返回一个值,该值指示此实例是否与指定的对象相等。

(继承自 Attribute)
GetHashCode()

返回此实例的哈希代码。

(继承自 Attribute)
GetType()

获取当前实例的 Type

(继承自 Object)
IsDefaultAttribute()

在派生类中重写时,指示此实例的值是否是派生类的默认值。

(继承自 Attribute)
Match(Object)

当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。

(继承自 Attribute)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

显式接口实现

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。

(继承自 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。

(继承自 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。

(继承自 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对某一对象公开的属性和方法的访问。

(继承自 Attribute)

适用于

另请参阅