private static VsHierarchyItem GetHierarchyItemForProject(EnvDTE.Project project) { IVsHierarchy hierarchy; // Get the solution IVsSolution solution = ServiceLocator.GetGlobalService<SVsSolution, IVsSolution>(); int hr = solution.GetProjectOfUniqueName(project.GetUniqueName(), out hierarchy); if (hr != VSConstants.S_OK) { Marshal.ThrowExceptionForHR(hr); } return new VsHierarchyItem(hierarchy); }