InterfaceTypeAttribute クラス

定義

COM への公開時に、マネージド インターフェイスがデュアル、ディスパッチ専用、または IUnknown 専用のいずれであるかを示します。

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
属性

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

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)

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

InterfaceTypeAttribute(Int16)

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

プロパティ

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)

適用対象

こちらもご覧ください