ComVisibleAttribute Class
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
Controls accessibility of an individual managed type or member, or of all types within an assembly, to COM.
Inheritance Hierarchy
System. . :: . .Object
System. . :: . .Attribute
System.Runtime.InteropServices..::..ComVisibleAttribute
Namespace: System.Runtime.InteropServices
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
<AttributeUsageAttribute(AttributeTargets.Assembly Or AttributeTargets.Class Or AttributeTargets.Struct Or AttributeTargets.Enum Or AttributeTargets.Method Or AttributeTargets.Property Or AttributeTargets.Field Or AttributeTargets.Interface Or AttributeTargets.Delegate, Inherited := False)> _
Public NotInheritable Class ComVisibleAttribute _
Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Enum|AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Interface|AttributeTargets.Delegate, Inherited = false)]
public sealed class ComVisibleAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Assembly|AttributeTargets::Class|AttributeTargets::Struct|AttributeTargets::Enum|AttributeTargets::Method|AttributeTargets::Property|AttributeTargets::Field|AttributeTargets::Interface|AttributeTargets::Delegate, Inherited = false)]
public ref class ComVisibleAttribute sealed : public Attribute
[<Sealed>]
[<AttributeUsageAttribute(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Enum|AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Interface|AttributeTargets.Delegate, Inherited = false)>]
type ComVisibleAttribute =
class
inherit Attribute
end
public final class ComVisibleAttribute extends Attribute
The ComVisibleAttribute type exposes the following members.
Constructors
Name | Description | |
---|---|---|
ComVisibleAttribute | Initializes a new instance of the ComVisibleAttribute class. |
Top
Properties
Name | Description | |
---|---|---|
Value | Gets a value that indicates whether the COM type is visible. |
Top
Methods
Name | Description | |
---|---|---|
Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Top
Remarks
You can apply this attribute to assemblies, interfaces, classes, structures, delegates, enumerations, fields, methods, or properties.
The default is true, which indicates that the managed type is visible to COM. This attribute is not needed to make public managed assemblies and types visible; they are visible to COM by default. Only public types can be made visible. The attribute cannot be used to make an otherwise internal or protected type visible to COM or to make members of a nonvisible type visible.
Setting the attribute to false on the assembly hides all public types within the assembly. You can selectively make types within the assembly visible by setting the individual types to true. Setting the attribute to false on a specific type hides that type and its members. However, you cannot make members of a type visible if the type is invisible. Setting the attribute to false on a type prevents that type from being exported to a type library; classes are not registered; interfaces are never responsive to unmanaged QueryInterface calls.
Unless you explicitly set a class and its members to false, inherited classes can expose to COM base class members that are invisible in the original class. For example, if you set ClassA to false and do not apply the attribute to its members, the class and its members are invisible to COM. However, if you derive ClassB from ClassA and export ClassB to COM, ClassA members become visible base class members of ClassB.
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.