InterfaceTypeAttribute クラス

定義

マネージド インターフェイスが COM に公開されるときに、デュアル インターフェイス、ディスパッチ専用インターフェイス、または IUnknown -only かどうかを示します。

public ref class InterfaceTypeAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Interface, Inherited=false)]
public sealed class InterfaceTypeAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Interface, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class InterfaceTypeAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Interface, Inherited=false)>]
type InterfaceTypeAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Interface, Inherited=false)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type InterfaceTypeAttribute = class
    inherit Attribute
Public NotInheritable Class InterfaceTypeAttribute
Inherits Attribute
継承
InterfaceTypeAttribute
属性

次の例は、 InterfaceTypeAttribute がインターフェイスを COM に公開する方法を制御する方法を示しています。

using namespace System::Runtime::InteropServices;

//Interface is exposed to COM as dual.
interface class IMyInterface1{};

//Insert code here.
//Interface is exposed to COM as IDispatch.

[InterfaceTypeAttribute(ComInterfaceType::InterfaceIsIDispatch)]
interface class IMyInterface2{};
//Insert code here.
using System.Runtime.InteropServices;

//Interface is exposed to COM as dual.
interface IMyInterface1
{
    //Insert code here.
}

//Interface is exposed to COM as IDispatch.
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
interface IMyInterface2
{
    //Insert code here.
}
Imports System.Runtime.InteropServices

'Interface is exposed to COM as dual.
Interface IMyInterface1
     'Insert code here.
End Interface

'Interface is exposed to COM as IDispatch.
<InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)> _
Interface IMyInterface2
    'Insert code here.
End Interface

注釈

この属性はインターフェイスに適用できます。

既定では、 Tlbexp.exe (タイプ ライブラリ エクスポーター) は、マネージド インターフェイスをデュアル インターフェイスとして COM に公開し、遅延バインディングの柔軟性や早期バインディングのパフォーマンスを実現します。 ComInterfaceType列挙を使用すると、既定の動作をオーバーライドし、遅延バインディングのみまたは早期バインディングのみを指定できます。 たとえば、 InterfaceType (ComInterfaceType.InterfaceIsIDispatch) をインターフェイスに適用してメタデータを生成し、呼び出し元を遅延バインディングのみに制限できます。 IDispatch インターフェイスから派生するインターフェイスはデュアルであることがよくありますが、InterfaceIsIDispatch列挙メンバーでは、インターフェイス メソッドの遅延バインディング呼び出しのみが許可されます。 この属性は、インターフェイスのマネージド ビューには影響しません。 インターフェイスを COM に公開する方法の詳細については、「 エクスポートされた型変換」を参照してください。

Tlbimp.exe (タイプ ライブラリ インポーター) は、インポートされた非インターフェイスにもこの属性を適用します。インターフェイスがディスパッチ専用または IUnknown -only であることを示すために、適切な列挙メンバーを適用します。

コンストラクター

名前 説明
InterfaceTypeAttribute(ComInterfaceType)

指定したComInterfaceType列挙メンバーを使用して、InterfaceTypeAttribute クラスの新しいインスタンスを初期化します。

InterfaceTypeAttribute(Int16)

指定したComInterfaceType列挙メンバーを使用して、InterfaceTypeAttribute クラスの新しいインスタンスを初期化します。

プロパティ

名前 説明
TypeId

派生クラスで実装されている場合は、この Attributeの一意の識別子を取得します。

(継承元 Attribute)
Value

インターフェイスを COM に公開する方法を説明する ComInterfaceType 値を取得します。

メソッド

名前 説明
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)

適用対象

こちらもご覧ください