ProjectRootElement.TryOpen Method (String, ProjectCollection)
Gets the project root in the specified project collection that was loaded into memory from the specified file path. or null if it is not currently in memory.
MSBuild is now included in Visual Studio instead of the .NET Framework. You can use MSBuild 12.0 side-by-side with versions previously deployed with the .NET Framework.For more information, see What's New in MSBuild 12.0.
Namespace: Microsoft.Build.Construction
Assembly: Microsoft.Build (in Microsoft.Build.dll)
Syntax
'Declaration
Public Shared Function TryOpen ( _
path As String, _
projectCollection As ProjectCollection _
) As ProjectRootElement
public static ProjectRootElement TryOpen(
string path,
ProjectCollection projectCollection
)
public:
static ProjectRootElement^ TryOpen(
String^ path,
ProjectCollection^ projectCollection
)
static member TryOpen :
path:string *
projectCollection:ProjectCollection -> ProjectRootElement
public static function TryOpen(
path : String,
projectCollection : ProjectCollection
) : ProjectRootElement
Parameters
path
Type: System.StringThe path of the ProjectRootElement, cannot be null.
projectCollection
Type: Microsoft.Build.Evaluation.ProjectCollectionThe project collection to search for the project root.
Return Value
Type: Microsoft.Build.Construction.ProjectRootElement
Returns the project root. Returns null if no project was loaded into memory from the specified file path.
Remarks
It is possible for ProjectRootElements to be brought into memory and discarded due to memory pressure. If TryOpen returns null it does not indicate that the project root has never been loaded, only that it is not currently in memory.
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see dd66cd4c-b087-415f-9c3e-94e3a1835f74.