Attributes in C# are used to provide information at design time and as well as at run-time. There are different types of attributes available in C# to interoperate with COM components.
COMImport attribute: COMImport attribute marks the class as an externally implemented COM class and a class declaration enables the use of a C# name to refer to a COM class.
[AttributeUsage(AttributeTargets.Class)]
public class COMImportAttribute : System.Attribute
{
public COMImportAttribute() { }
}
COMVisibility attribute: This attribute is used to specify whether or not a class or interface is visible in COM.
public class COMVisibilityAttribute: System.Attribute
{
public COMVisibilityAttribute(System.Interop.ComVisibility value) {}
public ComVisibilityAttribute Value { get {} }
}
There are many other attributes. Those are
All these above attributes are used to interoperate with COM components from C#.