InterfaceTypeAttribute クラス
アセンブリ: mscorlib (mscorlib.dll 内)
構文
<AttributeUsageAttribute(AttributeTargets.Interface, Inherited:=False)> _ <ComVisibleAttribute(True)> _ Public NotInheritable Class InterfaceTypeAttribute Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Interface, Inherited=false)] [ComVisibleAttribute(true)] public sealed class InterfaceTypeAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Interface, Inherited=false)] [ComVisibleAttribute(true)] public ref class InterfaceTypeAttribute sealed : public Attribute
タイプ ライブラリ エクスポータ (Tlbexp.exe) は既定では、マネージ インターフェイスをデュアル インターフェイスとして COM に公開します。これによって、遅延バインディングの柔軟性と事前バインディングのパフォーマンスを得ることができます。ComInterfaceType 列挙体を使用すると、既定の動作をオーバーライドして、遅延バインディングだけ、または事前バインディングだけを指定できます。たとえば、InterfaceType (ComInterfaceType.InterfaceIsIDispatch) をインターフェイスに適用すると、呼び出し元を遅延バインディングだけに制限するメタデータを生成できます。IDispatch インターフェイスから継承したインターフェイスの多くはデュアル インターフェイスですが、InterfaceIsIDispatch 列挙体メンバを使用すると、インターフェイスのメソッドに対して遅延バインディング呼び出しだけを許可できます。この属性は、インターフェイスのマネージ ビューには影響を与えません。インターフェイスを COM に公開する方法の詳細については、「エクスポート時の型の変換」を参照してください。
タイプ ライブラリ インポータ (Tlbimp.exe) はまた、インポートされた非デュアル インターフェイスにこの属性を適用します。適切な列挙体メンバを適用することによって、インターフェイスがディスパッチ専用か IUnknown 専用かを示します。
InterfaceTypeAttribute でインターフェイスを COM に公開する方法を制御する方法を次の例に示します。
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
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. }
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.
import System.Runtime.InteropServices.*; //Interface is exposed to COM as dual. interface IMyInterface1 { //Insert code here. } //IMyInterface1 //Interface is exposed to COM as IDispatch. /** @attribute InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch) */ interface IMyInterface2 { //Insert code here. } //IMyInterface2
System.Attribute
System.Runtime.InteropServices.InterfaceTypeAttribute
プラットフォーム
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
- InterfaceTypeAttribute クラスのページへのリンク