Reference3.Aliases Property

Definition

Gets or sets the aliased names for the specified reference. This property applies to Visual C# only.

public:
 property System::String ^ Aliases { System::String ^ get(); void set(System::String ^ value); };
public:
 property Platform::String ^ Aliases { Platform::String ^ get(); void set(Platform::String ^ value); };
[System.Runtime.InteropServices.DispId(123)]
[get: System.Runtime.InteropServices.DispId(123)]
[set: System.Runtime.InteropServices.DispId(123)]
public string Aliases { get; set; }
[<System.Runtime.InteropServices.DispId(123)>]
[<get: System.Runtime.InteropServices.DispId(123)>]
[<set: System.Runtime.InteropServices.DispId(123)>]
member this.Aliases : string with get, set
Public Property Aliases As String

Property Value

String

A string representing the name of the aliases.

Attributes

Examples

This example tests to see if a project is a Visual C# project, and it then lists all the aliases for the project references. Open a Visual C# project before running this example. To run this example as an add-in, see How to: Compile and Run the Automation Object Model Code Examples.

Imports VSLangProj  
Imports VSLangProj2  
Imports VSLangProj80  
Public Sub OnConnection(ByVal application As Object,_  
 ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _  
 ByRef custom As Array) Implements IDTExtensibility2.OnConnection  
    applicationObject = CType(application, DTE2)  
    addInInstance = CType(addInInst, AddIn)  
    DisplayAliases(applicationObject)  
End Sub  
Public Sub DisplayAliases(ByVal dte As DTE2)  
    ' The first project is a Visual Basic or C# project.  
    Dim vsProject As VSProject2 = _  
    CType(applicationObject.Solution.Projects.Item(1).Object, _  
    VSProject2)  
    Dim aRef As Reference3  
    Dim refStr As String  
    refStr = ""  
    If vsProject.Project.Kind = PrjKind.prjKindCSharpProject Then  
        For Each aRef In vsProject.References  
            refStr += (aRef.Name & " " & aRef.Aliases & vbCr)  
         Next  
         MsgBox(refStr)  
    Else  
         MsgBox("The project is not a C# project")  
    End If  
End Sub  

Remarks

In Visual C#, you can use one or more alternate names, or aliases, for reference names in projects. This property allows you to view or set the aliases.

Applies to