This documentation is archived and is not being maintained.

ComAliasNameAttribute Class

Indicates the COM alias for a parameter or field type.

For a list of all members of this type, see ComAliasNameAttribute Members.


[Visual Basic]
<AttributeUsage(AttributeTargets.Property Or AttributeTargets.Field _
   Or AttributeTargets.Parameter Or AttributeTargets.ReturnValue)>
NotInheritable Public Class ComAliasNameAttribute
   Inherits Attribute
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field
   | AttributeTargets.Parameter | AttributeTargets.ReturnValue)]
public sealed class ComAliasNameAttribute : Attribute
[AttributeUsage(AttributeTargets::Property |
   AttributeTargets::Field | AttributeTargets::Parameter |
public __gc __sealed class ComAliasNameAttribute : public
   AttributeUsage(AttributeTargets.Property | AttributeTargets.Field |
   AttributeTargets.Parameter | AttributeTargets.ReturnValue)
class ComAliasNameAttribute extends Attribute

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.


You can apply this attribute to parameters, fields, properties, or return values.


[Visual Basic, C#, C++] In the following type library, OLE_COLOR is an alias for int. During import the arguments of the Color accessor are marked with the ComAliasNameAttribute to indicate that type library refers to them as OLE_COLOR.

typedef int OLE_COLOR;  

interface Baz {
 HRESULT SetColor([in] OLE_COLOR cl);
 HRESULT GetColor([out, retval] OLE_COLOR *cl);

[Visual Basic, C#, C++] imported as:

[Visual Basic] 
Interface Baz
    Sub SetColor( <ComAliasName("stdole.OLE_COLOR")> cl As Integer)
    Function GetColor() As <ComAliasName("stdole.OLE_COLOR")> Integer
End Interface

interface Baz {
 void SetColor([ComAliasName("stdole.OLE_COLOR")] int cl);
 [return: ComAliasName("stdole.OLE_COLOR")] int GetColor();

__gc __interface Baz {
 void SetColor([ComAliasName(S"stdole.OLE_COLOR")] int cl);
 [returnvalue: ComAliasName(S"stdole.OLE_COLOR")] int GetColor();

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Namespace: System.Runtime.InteropServices

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: Mscorlib (in Mscorlib.dll)

See Also

ComAliasNameAttribute Members | System.Runtime.InteropServices Namespace