VSProject.References Property

Gets the References collection for the project. Read-only.

Namespace:  VSLangProj
Assembly:  VSLangProj (in VSLangProj.dll)

References References { get; }

Property Value

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

In order 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.

' Macro Editor
' Assuming that the first project in the solution is a Visual Basic or C#
' application, this routine lists the references in the project.
Imports VSLangProj
Sub ListReferences()
   ' Retrieve the VSProject object.
   Dim theVSProject As VSProject = _
      CType(DTE.Solution.Projects.Item(1).Object, VSProject)

   ' Retrieve the references collection.
   Dim refs As References = theVSProject.References

   ' Create a string list of the reference names.
   Dim refList As String = ""
   Dim aRef As Reference
   For Each aRef In refs
      refList &= aRef.Identity & ControlChars.CrLf
   Next
   MsgBox(refList)
End Sub

Community Additions

Show: