References Property
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

VSProject2.References Property 

Gets the References collection for the project.

Namespace: VSLangProj80
Assembly: VSLangProj80 (in vslangproj80.dll)

References References { get; }
/** @property */
References get_References ()

function get References () : References

Property Value

A References collection containing Reference objects, each one representing a reference.

To write code against an external component, your project must first contain a reference to that component. A reference can be made to three types of components: .NET assemblies, COM automation servers and controls, and other projects within the same solution that expose components.

To run this example as an add-in, see How to: Compile and Run the Automation Object Model Code Examples. This example assumes that the first project in the solution is a Visual Basic Visual C#, or Visual J# project.

// Add-in.
// Assuming that the first project in the solution is a Visual Basic, 
// C#, or J# application, this routine lists the references 
// in the project.
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 ListReferences( DTE2 dte ) 
    // Retrieve the VSProject2 object.
    VSProject2 theVSProject = ( ( VSProject2 )
(applicationObject.Solution.Projects.Item( 1 ).Object ) ); 
    // Retrieve the references collection.
    References refs = theVSProject.References; 
    // Create a string list of the reference names.
    string refList = ""; 
    Reference3 aRef = null; 
    foreach ( VSLangProj80.Reference3 temp in refs ) 
        aRef = temp; 
        refList += aRef.Identity + "\n"; 
    MessageBox.Show( refList); 
© 2015 Microsoft