Click to Rate and Give Feedback

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
ComSourceInterfacesAttribute Class

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

Namespace:  System.Runtime.InteropServices
Assembly:  mscorlib (in mscorlib.dll)
Visual Basic (Declaration)
<ComVisibleAttribute(True)> _
<AttributeUsageAttribute(AttributeTargets.Class, Inherited := True)> _
Public NotInheritable Class ComSourceInterfacesAttribute _
    Inherits Attribute
Visual Basic (Usage)
Dim instance As ComSourceInterfacesAttribute
C#
[ComVisibleAttribute(true)]
[AttributeUsageAttribute(AttributeTargets.Class, Inherited = true)]
public sealed class ComSourceInterfacesAttribute : Attribute
Visual C++
[ComVisibleAttribute(true)]
[AttributeUsageAttribute(AttributeTargets::Class, Inherited = true)]
public ref class ComSourceInterfacesAttribute sealed : public Attribute
JScript
public final class ComSourceInterfacesAttribute extends Attribute

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 How to: Raise Events Handled by a COM Sink.

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.
}

Visual C++
using namespace System::Runtime::InteropServices;

[ComSourceInterfacesAttribute("ButtonEventsLib.ButtonEvents, ButtonEventsLib")]
public ref class Baz{};


JScript
import System.Runtime.InteropServices;

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

System..::.Object
  System..::.Attribute
    System.Runtime.InteropServices..::.ComSourceInterfacesAttribute
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 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

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

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker