ComVisibleAttribute 클래스

정의

개별 관리되는 형식이나 멤버의 또는 어셈블리 내 모든 형식의 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
상속
ComVisibleAttribute
특성

예제

다음 예제에서는 클래스의 COM에 대한 표시 유형을 제어하여 해당 멤버가 보이지 않도록 하는 방법을 보여줍니다. 을 false (SampleClassMyClassVisual Basic 예제의 경우)false로 설정하고 ComVisibleAttributeMyProperty에서 MyMethod 를 설정하면 상속을 통해 멤버가 실수로 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)

ComVisibleAttribute 클래스의 새 인스턴스를 초기화합니다.

속성

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)

적용 대상

추가 정보