Export (0) Print
Expand All

ComSourceInterfacesAttribute Class

Identifies a list of interfaces that are exposed as COM event sources for the attributed class.

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

System.Object
   System.Attribute
      System.Runtime.InteropServices.ComSourceInterfacesAttribute

[Visual Basic]
<AttributeUsage(AttributeTargets.Class)>
NotInheritable Public Class ComSourceInterfacesAttribute
   Inherits Attribute
[C#]
[AttributeUsage(AttributeTargets.Class)]
public sealed class ComSourceInterfacesAttribute : Attribute
[C++]
[AttributeUsage(AttributeTargets::Class)]
public __gc __sealed class ComSourceInterfacesAttribute : public
   Attribute
[JScript]
public
   AttributeUsage(AttributeTargets.Class)
class ComSourceInterfacesAttribute 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 classes.

You apply this attribute to a managed class to identify the event interfaces that the class exposes as COM connection points. An event interface contains methods that map to the event members of the class. The class event name and the interface method name must be the same. This attribute can accommodate up to four source interfaces for a class by passing the type of the source interface to the appropriate constructor, which take between one and four type arguments. For classes that want to expose more than four source interfaces, the string version of the constructor can be used. For additional information about exposing .NET events to COM clients, see Raising Events Handled by a COM Sink.

Example

The following example shows how to apply the ComSourceInterfacesAttribute to connect the event sink interface to a class by passing the namespace and event sink interface.

[Visual Basic] 
Imports System.Runtime.InteropServices

<ComSourceInterfacesAttribute("ButtonEventsLib.ButtonEvents, ButtonEventsLib")> _
public Class Baz
    'Insert code here.
End Class

[C#] 
using System.Runtime.InteropServices;

[ComSourceInterfacesAttribute("ButtonEventsLib.ButtonEvents, ButtonEventsLib")]
public class Baz 
{
   //Insert code here.
}

[C++] 
using namespace System::Runtime::InteropServices;

[ComSourceInterfacesAttribute(S"ButtonEventsLib.ButtonEvents, ButtonEventsLib")]
public __gc class Baz 
{
   //Insert code here.
};

[JScript] 
import System.Runtime.InteropServices;

ComSourceInterfacesAttribute("ButtonEventsLib.ButtonEvents, ButtonEventsLib") public class Baz 
{
   //Insert code here.
}

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

ComSourceInterfacesAttribute Members | System.Runtime.InteropServices Namespace

Show:
© 2014 Microsoft