locked
VSPackage: determine the load status of a project/IVsHierarchy RRS feed

  • Question


  • If I have an IVsHierarchy instance, how can I determine the load status of the corresponding project within the solution? I figure there must be some way to do this, as IVsSolution4 methods must also make use of that information.

    The only workaround I have found up to now is to get the list of DTE.Project instances from the DTE.Solution.Projects collection, which AFAIK corresponds to the list of loaded projects, then map these to IVsHierarchy instances, and compute the difference: If an IVsHierarchy has a corresponding Project, it is loaded, otherwise it is not.

    Any better approach for this?

    Matthias


    • Edited by Thriftweed Wednesday, October 31, 2012 8:52 AM
    Wednesday, October 31, 2012 8:08 AM

Answers

  • I believe you can query for VSHPROPID5::ProjectUnloadStatus, real (loaded) hierarchies will likely return a failure from the GetProperty call as they won't recognize the property. The 'stub hierarchy', which is the hierarchy that represents unloaded projects, should recognize the property and return some value from _VsProjectUnloadStatus, though if all you care about is loaded/unloaded then simply seeing if GetProperty doesn't fail for ProjectUnloadStatus should suffice.

    Ryan

    • Marked as answer by Ego Jiang Friday, November 9, 2012 9:18 AM
    Wednesday, October 31, 2012 2:58 PM

All replies

  • I believe you can query for VSHPROPID5::ProjectUnloadStatus, real (loaded) hierarchies will likely return a failure from the GetProperty call as they won't recognize the property. The 'stub hierarchy', which is the hierarchy that represents unloaded projects, should recognize the property and return some value from _VsProjectUnloadStatus, though if all you care about is loaded/unloaded then simply seeing if GetProperty doesn't fail for ProjectUnloadStatus should suffice.

    Ryan

    • Marked as answer by Ego Jiang Friday, November 9, 2012 9:18 AM
    Wednesday, October 31, 2012 2:58 PM
  • I've also used IVsSolution.GetProjectEnum specifying a value of EPF_UNLOADEDINSOLUTION.

    -kirk

    Wednesday, October 31, 2012 8:00 PM