ClassInterfaceType 列挙体とは? わかりやすく解説

ClassInterfaceType 列挙体

クラスに対して生成するクラス インターフェイスの型を識別します。

名前空間: System.Runtime.InteropServices
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Enumeration ClassInterfaceType
Dim instance As ClassInterfaceType
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public enum ClassInterfaceType
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public enum class ClassInterfaceType
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public enum ClassInterfaceType
SerializableAttribute 
ComVisibleAttribute(true) 
public enum ClassInterfaceType
メンバメンバ
 メンバ説明
AutoDispatchクラスCOM クライアントに対して遅延バインディングだけをサポートすることを示しますクラスディスパッチ インターフェイスは、要求に応じて自動的に COM クライアント公開されます。タイプ ライブラリ エクスポータ (Tlbexp.exe) によって生成されるタイプ ライブラリには、クライアントがこのディスパッチ インターフェイスの DISPID をキャッシュないようにするために、そのインターフェイス型情報含まれません。クライアントがこのディスパッチ インターフェイスに対して実行できるのは遅延バインディングだけであるため、ClassInterfaceAttribute説明したようなバージョン管理問題は、このインターフェイスでは発生しません。 

これは、ClassInterfaceAttribute既定設定です。

AutoDualクラスに対してデュアル クラス インターフェイス自動的に生成しCOM公開することを示します型情報は、クラス インターフェイスに対して作成されタイプ ライブラリ公開されます。ClassInterfaceAttribute説明したようなバージョン管理制約があるため、AutoDual使用しないことを強くお勧めます。 
.NET Compact Framework によるサポートNoneクラスに対してクラス インターフェイス生成しないことを示しますインターフェイス明示的に実装ていないクラスには、IDispatch インターフェイス通じた遅延バインディングによってしかアクセスできません。これは、ClassInterfaceAttribute推奨値です。このクラス明示的に実装しているインターフェイス通じて機能公開するには、ClassInterfaceType.None使用唯一の方法です。 

タイプ ライブラリ エクスポータ (Tlbexp.exe) は、クラスが 1 番目に実装しているパブリックCOM 参照可能なインターフェイスを、コクラスの既定インターフェイスとして公開します.NET Framework Version 2.0 からは、ComDefaultInterfaceAttribute 属性使用してCOM公開される既定インターフェイス指定できますクラス実装しているインターフェイスない場合は、基本クラスが 1 番目に実装しているパブリックCOM 参照可能なインターフェイス既定インターフェイスとなります。このとき、最後に派生した基本クラスから逆順検索されます。クラスもその基本クラスインターフェイス実装ていない場合、Tlbexp.exe は _Object既定インターフェイスとして公開します

解説解説

この列挙体は、ClassInterfaceAttribute 属性組み合わせて使用します

使用例使用例

ClassInterfaceAttribute を型に適用しClassInterfaceType設定する例を次に示しますこの方法で定義されクラスは、アンマネージ COM から使用できます

using System;
using System.Runtime.InteropServices;

// Have the CLR expose a class interface (derived from IDispatch) for
 this type.
// COM clients can call the  members of this class using the Invoke
 method from the IDispatch interface.
[ClassInterface(ClassInterfaceType.AutoDispatch)]
public class AClassUsableViaCOM
{
    public AClassUsableViaCOM() { }

    public Int32 Add(Int32 x, Int32 y) { return
 x + y; }
}

// The CLR does not expose a class interface for this type.
// COM clients can call the members of this class using the methods
 from the IComparable interface.
[ClassInterface(ClassInterfaceType.None)]
public class AnotherClassUsableViaCOM : IComparable
{
    public AnotherClassUsableViaCOM() { }

    Int32 IComparable.CompareTo(Object o) { return 0; }
}
using namespace System;
using namespace System::Runtime::InteropServices;

// Have the CLR expose a class interface (derived from IDispatch)
// for this type. COM clients can call the  members of this
// class using the Invoke method from the IDispatch interface.
[ClassInterface(ClassInterfaceType::AutoDispatch)]
public ref class AClassUsableViaCOM
{
public:
    AClassUsableViaCOM() 
    { 
    }

public:
    int Add(int x, int y)
    {
        return x + y;
    }
};

// The CLR does not expose a class interface for this type.
// COM clients can call the members of this class using
// the methods from the IComparable interface.
[ClassInterface(ClassInterfaceType::None)]
public ref class AnotherClassUsableViaCOM :
 public IComparable
{
public:
    AnotherClassUsableViaCOM() 
    { 
    }

    virtual int CompareTo(Object^ o) = IComparable::CompareTo
    {
        return 0;
    }
};
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
System.Runtime.InteropServices 名前空間
その他の技術情報
タイプ ライブラリ エクスポータ (Tlbexp.exe)


このページでは「.NET Framework クラス ライブラリ リファレンス」からClassInterfaceType 列挙体を検索した結果を表示しています。
Weblioに収録されているすべての辞書からClassInterfaceType 列挙体を検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からClassInterfaceType 列挙体を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「ClassInterfaceType 列挙体」の関連用語

ClassInterfaceType 列挙体のお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ClassInterfaceType 列挙体のページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS