共用方式為


VSProject.References Property

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

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

Syntax

'Declaration
ReadOnly Property References As References
References References { get; }
property References^ References {
    References^ get ();
}
abstract References : References with get
function get References () : References

Property Value

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

Remarks

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.

Examples

[Visual Basic]

' 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

.NET Framework Security

See Also

Reference

VSProject Interface

VSLangProj Namespace