Reference3.Path Property


Gets the path to the reference file.

 property System::String ^ Path { System::String ^ get(); };
 property Platform::String ^ Path { Platform::String ^ get(); };
[get: System.Runtime.InteropServices.DispId(8)]
public string Path { get; }
[<get: System.Runtime.InteropServices.DispId(8)>]
member this.Path : string
Public ReadOnly Property Path As String

Property Value


A string representing the path.




This example displays the name and the path for the first reference in an open Visual Basic or Visual C# project. 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)  
End Sub  
Sub GetPath(ByVal dte As DTE2)  
    Dim aProject As Project  
    Dim aVSProject As VSProject2  
    ' The first project is a Visual Basic or C# project.  
    aProject = applicationObject.Solution.Projects.Item(1)  
    aVSProject = _  
    CType(applicationObject.Solution.Projects.Item(1).Object, _  
    Dim newRef As Reference3  
    newRef = CType(aVSProject.References.Item(1), Reference3)  
    MsgBox("The name of the first reference in the project is: "   
    & newRef.Name & vbCr & "its path is: " & newRef.Path)  
End Sub  
using System.Windows.Forms;  
using VSLangProj;  
using VSLangProj2;  
using VSLangProj80;  
public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)  
    applicationObject = (DTE2)application;  
    addInInstance = (AddIn)addInInst;  
public void GetPath(DTE2 dte)  
    // The first project is a Visual Basic or C# project.  
    VSProject2 aVSProject =  
    Reference3 aRef = null;  
    aRef = ((Reference3)(aVSProject.References.Item(1)));  
    MessageBox.Show("The  first reference in the project is: "   
+ aRef.Name +"\n" + "and its path is: " + aRef.Path);  


Path returns the path and file name of the reference, if it can be resolved. If the path cannot be resolved, then a blank string is returned. For information on resolving references, see Add.

The path cannot be a UNC or URL.

Applies to