ClassInterfaceAttribute クラスとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ClassInterfaceAttribute クラスの意味・解説 

ClassInterfaceAttribute クラス

インターフェイス生成される場合に、COM公開されるクラスに対して生成されるクラス インターフェイスの型を示します

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

<ComVisibleAttribute(True)> _
<AttributeUsageAttribute(AttributeTargets.Assembly Or AttributeTargets.Class,
 Inherited:=False)> _
Public NotInheritable Class
 ClassInterfaceAttribute
    Inherits Attribute
Dim instance As ClassInterfaceAttribute
[ComVisibleAttribute(true)] 
[AttributeUsageAttribute(AttributeTargets.Assembly|AttributeTargets.Class, Inherited=false)]
 
public sealed class ClassInterfaceAttribute
 : Attribute
[ComVisibleAttribute(true)] 
[AttributeUsageAttribute(AttributeTargets::Assembly|AttributeTargets::Class, Inherited=false)]
 
public ref class ClassInterfaceAttribute sealed
 : public Attribute
/** @attribute ComVisibleAttribute(true) */ 
/** @attribute AttributeUsageAttribute(AttributeTargets.Assembly|AttributeTargets.Class,
 Inherited=false) */ 
public final class ClassInterfaceAttribute
 extends Attribute
ComVisibleAttribute(true) 
AttributeUsageAttribute(AttributeTargets.Assembly|AttributeTargets.Class, Inherited=false)
 
public final class ClassInterfaceAttribute
 extends Attribute
解説解説

この属性は、アセンブリまたはクラス適用できます

この属性は、タイプ ライブラリ エクスポータ (Tlbexp.exe) が属性付きクラスに対してクラス インターフェイス自動的に生成するかどうか制御しますクラス インターフェイスの名前は、クラス自体と同じですが、プリフィックスとしてアンダースコア付きます公開されると、クラス インターフェイスには、基本クラスから継承したメンバのほか、マネージ クラスすべての public メンバと非 static メンバ含まれます。マネージ クラスからクラス インターフェイスにはアクセスできませんが、マネージ クラス場合メンバ直接アクセスできるため、その必要はありません。Tlbexp.exe は、クラス インターフェイスに対して一意インターフェイス ID (IID) を生成します

クラス インターフェイスには、デュアル インターフェイスディスパッチ専用インターフェイスあります。必要があれば、クラス インターフェイス生成せずに、代わりにカスタム インターフェイス提供することもできますクラス インターフェイス公開するかどうかは、System.Runtime.InteropServices.ClassInterfaceType 列挙メンバ使用して指定しますClassInterfaceAttributeアセンブリ適用した場合個々クラスそれぞれの属性設定オーバーライドていない限り、この属性アセンブリ内のすべてのクラス適用されます。

クラス インターフェイス使用すると、クラスごとにインターフェイス明示的に定義する必要がなくなりますが、本運用アプリケーションでこれを使用することはできる限り避けてくださいデュアル クラス インターフェイスは、クライアントが、クラス変化による影響を受けやすい特定のインターフェイス レイアウトバインドできるようにします。たとえば、クラス インターフェイスCOM クライアント公開するマネージ クラスについて考えてます。最初バージョンクラスは、North メソッドSouth メソッド含んでます。アンマネージ クライアントは、1 番目のメソッドとして North2 番目のメソッドとして South提供するクラス インターフェイスバインドできます次にメソッド NorthSouth の間に新しEast メソッド挿入した、同じクラス次のバージョンについて考えます。アンマネージ クライアント以前クラス インターフェイス通じて新しクラスバインドようとした場合は、インターフェイス内のメソッド位置変更されしまっているため、South メソッド呼び出そうとしたときに、East メソッド呼び出されてしまうことになります。さらに、基本クラスレイアウト変更すると、すべての派生クラスクラス インターフェイスレイアウトにも影響ありますクラス直接バインドするマネージ クライアントでは、このようなバージョン問題発生しません。クラス インターフェイス使用に関するガイドラインについては、「クラス インターフェイス概要」を参照してください

タイプ ライブラリ インポータ (Tlbimp.exe) は、既存COM クラスマネージ インターフェイス公開することはないことを示すために、ClassInterfaceType.None 列挙メンバインポートされたクラスに対して常に適用します。

使用例使用例

ClassInterfaceType に AutoDispatch を指定して ClassInterfaceAttribute適用しMyClassIDispatch インターフェイス生成する例を次に示します

Imports System.Runtime.InteropServices

<ClassInterface(ClassInterfaceType.AutoDispatch)> _
Public Class SampleClass    
    ' Insert class members here.
End Class
using System.Runtime.InteropServices;

[ClassInterface(ClassInterfaceType.AutoDispatch)]
public class MyClass
{
   public MyClass() {}
}
using namespace System::Runtime::InteropServices;

[ClassInterface(ClassInterfaceType::AutoDispatch)]
public ref class MyClass
{
public:
   MyClass(){}

};

import System.Runtime.InteropServices.*;

/** @attribute ClassInterface(ClassInterfaceType.AutoDispatch)
 */
public class MyClass
{
    public MyClass()
    {
    } //MyClass
} //MyClass 
継承階層継承階層
System.Object
   System.Attribute
    System.Runtime.InteropServices.ClassInterfaceAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ClassInterfaceAttribute メンバ
System.Runtime.InteropServices 名前空間
ClassInterfaceType
その他の技術情報
タイプ ライブラリ エクスポータ (Tlbexp.exe)
タイプ ライブラリ インポータ (Tlbimp.exe)



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

辞書ショートカット

すべての辞書の索引

「ClassInterfaceAttribute クラス」の関連用語

ClassInterfaceAttribute クラスのお隣キーワード
検索ランキング

   

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



ClassInterfaceAttribute クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS