다음을 통해 공유


ProjectRootElement.TryOpen Method

Definition

Gets the project root in the global project collection that was loaded into memory from the specified file path. or null if it is not currently in memory.

Overloads

TryOpen(String)

Returns the ProjectRootElement for the given path if it has been loaded, or null if it is not currently in memory. Uses the global project collection.

TryOpen(String, ProjectCollection)

Returns the ProjectRootElement for the given path if it has been loaded, or null if it is not currently in memory. Uses the specified project collection.

TryOpen(String, ProjectCollection, Nullable<Boolean>)

Returns the ProjectRootElement for the given path if it has been loaded, or null if it is not currently in memory. Uses the specified project collection.

TryOpen(String)

Source:
ProjectRootElement.cs

Returns the ProjectRootElement for the given path if it has been loaded, or null if it is not currently in memory. Uses the global project collection.

public:
 static Microsoft::Build::Construction::ProjectRootElement ^ TryOpen(System::String ^ path);
public static Microsoft.Build.Construction.ProjectRootElement TryOpen (string path);
static member TryOpen : string -> Microsoft.Build.Construction.ProjectRootElement
Public Shared Function TryOpen (path As String) As ProjectRootElement

Parameters

path
String

The path of the ProjectRootElement, cannot be null.

Returns

The loaded ProjectRootElement, or null if it is not currently in memory.

Remarks

It is possible for ProjectRootElements to be brought into memory and discarded due to memory pressure. Therefore this method returning false does not indicate that it has never been loaded, only that it is not currently in memory.

Applies to

TryOpen(String, ProjectCollection)

Source:
ProjectRootElement.cs

Returns the ProjectRootElement for the given path if it has been loaded, or null if it is not currently in memory. Uses the specified project collection.

public:
 static Microsoft::Build::Construction::ProjectRootElement ^ TryOpen(System::String ^ path, Microsoft::Build::Evaluation::ProjectCollection ^ projectCollection);
public static Microsoft.Build.Construction.ProjectRootElement TryOpen (string path, Microsoft.Build.Evaluation.ProjectCollection projectCollection);
static member TryOpen : string * Microsoft.Build.Evaluation.ProjectCollection -> Microsoft.Build.Construction.ProjectRootElement
Public Shared Function TryOpen (path As String, projectCollection As ProjectCollection) As ProjectRootElement

Parameters

path
String

The path of the ProjectRootElement, cannot be null.

projectCollection
ProjectCollection

The ProjectCollection to load the project into.

Returns

The loaded ProjectRootElement, or null if it is not currently in memory.

Remarks

It is possible for ProjectRootElements to be brought into memory and discarded due to memory pressure. Therefore this method returning false does not indicate that it has never been loaded, only that it is not currently in memory.

Applies to

TryOpen(String, ProjectCollection, Nullable<Boolean>)

Source:
ProjectRootElement.cs

Returns the ProjectRootElement for the given path if it has been loaded, or null if it is not currently in memory. Uses the specified project collection.

public:
 static Microsoft::Build::Construction::ProjectRootElement ^ TryOpen(System::String ^ path, Microsoft::Build::Evaluation::ProjectCollection ^ projectCollection, Nullable<bool> preserveFormatting);
public static Microsoft.Build.Construction.ProjectRootElement TryOpen (string path, Microsoft.Build.Evaluation.ProjectCollection projectCollection, bool? preserveFormatting);
static member TryOpen : string * Microsoft.Build.Evaluation.ProjectCollection * Nullable<bool> -> Microsoft.Build.Construction.ProjectRootElement
Public Shared Function TryOpen (path As String, projectCollection As ProjectCollection, preserveFormatting As Nullable(Of Boolean)) As ProjectRootElement

Parameters

path
String

The path of the ProjectRootElement, cannot be null.

projectCollection
ProjectCollection

The ProjectCollection to load the project into.

preserveFormatting
Nullable<Boolean>

The formatting to open with. Must match the formatting in the collection to succeed.

Returns

The loaded ProjectRootElement, or null if it is not currently in memory.

Remarks

It is possible for ProjectRootElements to be brought into memory and discarded due to memory pressure. Therefore this method returning false does not indicate that it has never been loaded, only that it is not currently in memory.

Applies to