ComVisibleAttribute クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
個々のマネージド型またはマネージド メンバーから COM への、またはアセンブリ内のすべての型から COM へのアクセシビリティを制御します。
public ref class ComVisibleAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Delegate | System.AttributeTargets.Enum | System.AttributeTargets.Field | System.AttributeTargets.Interface | System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.Struct, Inherited=false)]
public sealed class ComVisibleAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Delegate | System.AttributeTargets.Enum | System.AttributeTargets.Field | System.AttributeTargets.Interface | System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.Struct, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class ComVisibleAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Delegate | System.AttributeTargets.Enum | System.AttributeTargets.Field | System.AttributeTargets.Interface | System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.Struct, Inherited=false)>]
type ComVisibleAttribute = class
inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Class | System.AttributeTargets.Delegate | System.AttributeTargets.Enum | System.AttributeTargets.Field | System.AttributeTargets.Interface | System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.Struct, Inherited=false)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type ComVisibleAttribute = class
inherit Attribute
Public NotInheritable Class ComVisibleAttribute
Inherits Attribute
- 継承
- 属性
例
次の例は、クラスの COM の可視性を制御して、そのメンバーが非表示になるようにする方法を示しています。 (SampleClass
Visual Basic例では) on MyClass
にfalse
設定ComVisibleAttribute
し、オンMyMethod
にfalse``MyProperty
することで、継承によってメンバーが誤って COM に公開されるのを回避できます。
using namespace System::Runtime::InteropServices;
[ComVisible(false)]
ref class MyClass
{
private:
int myProperty;
public:
MyClass()
{
//Insert code here.
}
[ComVisible(false)]
int MyMethod( String^ param )
{
return 0;
}
bool MyOtherMethod()
{
return true;
}
property int MyProperty
{
[ComVisible(false)]
int get()
{
return myProperty;
}
}
};
using System.Runtime.InteropServices;
[ComVisible(false)]
class MyClass
{
public MyClass()
{
//Insert code here.
}
[ComVisible(false)]
public int MyMethod(string param)
{
return 0;
}
public bool MyOtherMethod()
{
return true;
}
[ComVisible(false)]
public int MyProperty
{
get
{
return MyProperty;
}
}
}
Imports System.Runtime.InteropServices
<ComVisible(False)> _
Class SampleClass
Public Sub New()
'Insert code here.
End Sub
<ComVisible(False)> _
Public Function MyMethod(param As String) As Integer
Return 0
End Function
Public Function MyOtherMethod() As Boolean
Return True
End Function
<ComVisible(False)> _
Public ReadOnly Property MyProperty() As Integer
Get
Return MyProperty
End Get
End Property
End Class
注釈
この属性は、アセンブリ、インターフェイス、クラス、構造体、デリゲート、列挙型、フィールド、メソッド、またはプロパティに適用できます。
既定値は、 true
マネージド型が COM に表示されることを示します。 この属性は、パブリックマネージド アセンブリと型を表示するために必要ありません。既定では COM に表示されます。 型のみを public
表示できます。 この属性を使用して、COM に対してそれ以外の場合 internal
や protected
型を表示したり、非表示の型のメンバーを表示したりすることはできません。
アセンブリに属性を false
設定すると、アセンブリ内のすべての public
型が非表示になります。 アセンブリ内の型を選択的に表示するには、個々の型を に true
設定します。 属性 false
を特定の型に設定すると、その型とそのメンバーは非表示になります。 ただし、型が非表示の場合、型のメンバーを表示することはできません。 属性 false
を型に設定すると、その型はタイプ ライブラリにエクスポートされません。クラスは登録されません。インターフェイスはアンマネージ QueryInterface
呼び出しに対して応答しません。
クラスとそのメンバー false
を明示的に設定しない限り、継承されたクラスは、元のクラスで非表示になっている COM 基本クラス メンバーに公開できます。 たとえば、ClassA を設定し、そのメンバーに false
属性を適用しない場合、クラスとそのメンバーは COM に表示されません。 ただし、ClassA から ClassB を派生させ、ClassB を COM にエクスポートすると、ClassA メンバーは ClassB の参照可能な基底クラス メンバーになります。
エクスポート プロセスの詳細については、「 アセンブリからタイプ ライブラリへの変換の概要」を参照してください。
コンストラクター
ComVisibleAttribute(Boolean) |
|
プロパティ
TypeId |
派生クラスで実装されると、この Attribute の一意の識別子を取得します。 (継承元 Attribute) |
Value |
COM 型が参照可能かどうかを示す値を取得します。 |
メソッド
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) |