ComVisibleAttribute 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
개별 관리되는 형식이나 멤버의 또는 어셈블리 내 모든 형식의 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에 대한 표시 유형을 제어하여 해당 멤버가 보이지 않도록 하는 방법을 보여 주는 예제입니다. Visual Basic 예제에서 켜기 및SampleClass
MyProperty``MyMethod
false
켜기를 설정 ComVisibleAttribute
false
MyClass
하면 상속을 통해 실수로 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) |