Megosztás a következőn keresztül:


References.AddProject Method

Adds a new project reference to the project and returns the newly created Reference object.

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

Syntax

'Declaration
Function AddProject ( _
    pProject As Project _
) As Reference
Reference AddProject(
    Project pProject
)
Reference^ AddProject(
    [InAttribute] Project^ pProject
)
abstract AddProject : 
        pProject:Project -> Reference
function AddProject(
    pProject : Project
) : Reference

Parameters

  • pProject
    Type: EnvDTE.Project

    Required. The Project object to be added.

Return Value

Type: VSLangProj.Reference

Remarks

This method does not generate an error if a reference exists in the project with the same Identity, Culture, MajorVersion, MinorVersion, BuildNumber, and RevisionNumber as the new reference. That condition would indicate that the reference indicated by the bstrPath parameter has already been added to the project. Instead, the ProjectItem for the matching reference already in the project is returned.

If a reference with the same Identity but differing MajorVersion, MinorVersion, BuildNumber, RevisionNumber or Culture is found in the project, the method generates an error.

Examples

' Macro Editor    
Imports VSLangProj
' Add the second project as a reference to the first project.
Sub AddProjectExample()
   ' First project is a Visual Basic or C# project.
   Dim theVSProject As VSProject = _
      CType(DTE.Solution.Projects.Item(1).Object, VSProject)
        
   ' Second project is any type of project.
   Dim secondProject As Project = DTE.Solution.Projects.Item(2)
        
   ' AddProject returns the newly created Reference object.
   Dim newReference As Reference
   newReference = theVSProject.References.AddProject(secondProject)
End Sub

.NET Framework Security

See Also

Reference

References Interface

VSLangProj Namespace