VCProject.CanAddProjectReference(Object) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns whether it is okay to add the given project reference
public:
bool CanAddProjectReference(System::Object ^ proj);
public:
bool CanAddProjectReference(Platform::Object ^ proj);
bool CanAddProjectReference(winrt::Windows::Foundation::IInspectable const & proj);
[System.Runtime.InteropServices.DispId(846)]
public bool CanAddProjectReference (object proj);
[<System.Runtime.InteropServices.DispId(846)>]
abstract member CanAddProjectReference : obj -> bool
Public Function CanAddProjectReference (proj As Object) As Boolean
Parameters
- proj
- Object
The project reference.
Returns
true
if it is okay to add the given project reference; otherwise, false
.
- Attributes
Examples
See How to: Compile Example Code for Visual C++ Code Model Extensibility for information about how to compile and run this example.
CanAddProjectReference adds a second project as a reference to the first project, if possible.
' 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
Remarks
This method is generally used in conjunction with the AddProjectReference method. You use this method to determine whether it is okay to add a project reference, and if it is, then you call AddProjectReference.