Export (0) Print
Expand All

ComEventInterfaceAttribute Class

Identifies the source interface and the class that implements the methods of the event interface that is generated when a coclass is imported from a COM type library.

Namespace: System.Runtime.InteropServices
Assembly: mscorlib (in mscorlib.dll)

[AttributeUsageAttribute(AttributeTargets.Interface, Inherited=false)] 
[ComVisibleAttribute(true)] 
public sealed class ComEventInterfaceAttribute : Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Interface, Inherited=false) */ 
/** @attribute ComVisibleAttribute(true) */ 
public final class ComEventInterfaceAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Interface, Inherited=false) 
ComVisibleAttribute(true) 
public final class ComEventInterfaceAttribute extends Attribute

You can apply this attribute to interfaces, although the Type Library Importer (Tlbimp.exe) typically applies it for you when it imports a type library.

When a source interface is imported from a type library, any methods it implements are added as events to a generated event interface. Tlbimp.exe applies ComEventInterfaceAttribute to the event interface to identify the managed class that implements the methods of the event interface and implements the original source interface. The common language runtime uses this attribute at run time to perform the following tasks:

  • Associate events exposed by the interface to their implementation in the event provider class.

  • Link the events to the original COM source interface.

You rarely apply this attribute. However, if you plan to write source code that produces metadata that closely simulates metadata produced by Tlbimp.exe, you should create a event interface for each original source interface. For a detailed description about how Tlbimp.exe imports events, see Imported Member Conversion. For instruction about how to expose a COM event to a.NET client, see How to: Handle Events Raised by a COM Source.

System.Object
   System.Attribute
    System.Runtime.InteropServices.ComEventInterfaceAttribute

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft