Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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.

For a list of all members of this type, see ComEventInterfaceAttribute Members.

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

[Visual Basic]
<AttributeUsage(AttributeTargets.Interface)>
NotInheritable Public Class ComEventInterfaceAttribute
   Inherits Attribute
[C#]
[AttributeUsage(AttributeTargets.Interface)]
public sealed class ComEventInterfaceAttribute : Attribute
[C++]
[AttributeUsage(AttributeTargets::Interface)]
public __gc __sealed class ComEventInterfaceAttribute : public
   Attribute
[JScript]
public
   AttributeUsage(AttributeTargets.Interface)
class ComEventInterfaceAttribute extends Attribute

Thread Safety

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

Remarks

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 Handling Events Raised by a COM Source.

Requirements

Namespace: System.Runtime.InteropServices

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: Mscorlib (in Mscorlib.dll)

See Also

ComEventInterfaceAttribute Members | System.Runtime.InteropServices Namespace | Type Library Importer (Tlbimp.exe)

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.