ClassInterfaceType 列挙型
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
クラスに対して生成されるクラス インターフェイスの型を識別します。
public enum class ClassInterfaceType
public enum ClassInterfaceType
[System.Serializable]
public enum ClassInterfaceType
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum ClassInterfaceType
type ClassInterfaceType =
[<System.Serializable>]
type ClassInterfaceType =
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type ClassInterfaceType =
Public Enum ClassInterfaceType
- 継承
- 属性
フィールド
| 名前 | 値 | 説明 |
|---|---|---|
| None | 0 | クラスに対してクラス インターフェイスが生成されていないことを示します。 インターフェイスが明示的に実装されていない場合、クラスは
Tlbexp.exe (タイプ ライブラリ エクスポーター) は、クラスによって実装された最初のパブリック COM 可視インターフェイスを、コクラスの既定のインターフェイスとして公開します。 .NET Framework 2.0 以降のバージョンでは、ComDefaultInterfaceAttribute 属性を使用して COM に公開される既定のインターフェイスを指定できます。 クラスにインターフェイスが実装されていない場合、基底クラスによって実装される最初のパブリック COM 参照インターフェイスが既定のインターフェイスになります (最後に派生した基底クラスから始まり、後方に動作します)。 Tlbexp.exe は、クラスも基底クラスもインターフェイスを実装していない場合、 |
| AutoDispatch | 1 | クラスが COM クライアントの遅延バインディングのみをサポートすることを示します。 クラスの これは、 ClassInterfaceAttributeの既定の設定です。 |
| AutoDual | 2 | クラスに対してデュアル クラス インターフェイスが自動的に生成され、COM に公開されることを示します。 クラス インターフェイスの型情報が生成され、タイプ ライブラリに公開されます。
|
例
この例では、 ClassInterfaceAttribute を型に適用し、 ClassInterfaceTypeを設定する方法を示します。 この方法で定義されたクラスは、アンマネージ COM から使用できます。
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;
}
};
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; }
}
Imports 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 Sub New()
End Sub
Public Function Add(ByVal x As Int32, ByVal y As Int32) As Int32
Return x + y
End Function
End Class
' 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
Implements IComparable
Public Sub New()
End Sub
Function CompareTo(ByVal o As [Object]) As Int32 Implements IComparable.CompareTo
Return 0
End Function 'IComparable.CompareTo
End Class
注釈
この列挙型は、 ClassInterfaceAttribute 属性と組み合わせて使用されます。