共用方式為


VCProject.AddProjectReference 方法

將專案參考加入至專案。

命名空間:  Microsoft.VisualStudio.VCProjectEngine
組件:  Microsoft.VisualStudio.VCProjectEngine (在 Microsoft.VisualStudio.VCProjectEngine.dll 中)

語法

'宣告
Function AddProjectReference ( _
    proj As Object _
) As Object
Object AddProjectReference(
    Object proj
)
Object^ AddProjectReference(
    [InAttribute] Object^ proj
)
abstract AddProjectReference : 
        proj:Object -> Object 
function AddProjectReference(
    proj : Object
) : Object

參數

傳回值

型別:System.Object
表示專案參考的物件。

備註

您可以參考只能載入的專案。

範例

請參閱HOW TO:編譯專案模型擴充性的範例程式碼如需有關如何編譯及執行這個範例資訊。

AddProjectReference如果可能的話將做為參考至第一個專案中,第二個專案。

' Add a reference to Microsoft.VisualStudio.VCProjectEngine and have 
' two Visual C++ projects loaded before running this example.
Imports EnvDTE
Imports Microsoft.VisualStudio.VCProjectEngine
Public Module Module1
    Sub Test()
        Dim prj1, prj2 As VCProject
        prj1 = DTE.Solution.Projects.Item(1).Object
        prj2 = DTE.Solution.Projects.Item(2).Object
        ' Adds project 2 as a reference to project 1.
        If prj1.CanAddProjectReference(prj2) Then
            prj1.AddProjectReference(prj2)
        End If
    End Sub
End Module

.NET Framework 安全性

請參閱

參考

VCProject 介面

Microsoft.VisualStudio.VCProjectEngine 命名空間