Visual Studio and .NET Framework Home
EnvDTE.UIHierarchyItems does not work correctly in Visual Studio 2005 if Solution Explorer nodes are not opened previously
Carlos J. Quintero
as By Design
4/9/2007 3:26:05 AM
User(s) can reproduce this bug
When using a macro or add-in in VS 2005 to iterate the nodes of the Solution Explorer, some nodes inside solution folders are not returned if you didn't expand them previously by hand.
Visual Studio 2005 (All Products and Editions) Service Pack 1
Windows XP Professional
Operating System Language
Steps to Reproduce
- Create a macro like the following, which iterates recursively the nodes of the solution explorer:
Private Sub NavigateUIHierarchyItems(ByVal colUIHierarchyItems As UIHierarchyItems)
For Each objUIHierarchyItem As UIHierarchyItem In colUIHierarchyItems
- Create a blank solution in Visual Studio 2005 ("Other Project Types", "Visual Studio Solutions").
- Add to the solution a solution folder (such as "NewFolder1").
- Add to the solution folder a child solution folder (such as "NewFolder11").
- Add a project (such as "ClassLibrary1") to the child solution folder ("NewFolder11").
- Collapse the child solution folder ("NewFolder11") in the Solution Explorer.
- Collapse the solution folder ("NewFolder1") in the Solution Explorer.
- Close the solution (saving the changes).
- Open the solution again. The nodes in the Solution Explorer are collapsed.
- Run the macro. Notice that the project node ("ClassLibrary1") is not listed.
- Expand all the nodes in the Solution Explorer.
- Run the macro again. This time the project node ("ClassLibrary1") is listed.
The project node is not listed if the parent nodes were not expanded by hand previously.
Navigating the solution explorer programatically should list all nodes without requiring that the user expands the nodes by hand.
TAP Code (if applicable)
You can indicate your satisfaction with how Microsoft handled this issue by completing this quick
3 question survey
to post a comment.
Please enter a comment.
on 1/21/2008 at 7:18 AM
+1 for this as bug. This issue causes serious problems when developing VS addins. If this is by design, then this design is flawed and should be really reconsidered.
on 12/12/2007 at 6:40 AM
Actually I submitted (or was going to submit) a similar issue by myself, and I'm very surprised to learn that this behavior is considered 'by design'. What happens is that a specific API (UIHierarchyItems) Visual Studio exposes simply doesn't work as one can reasonably expect it to. Is it by design? If it is, please reconsider this design. For whatever reason it works the current way, any 'normal' external user / extender will think this is a BUG.
on 10/8/2007 at 12:30 PM
By design? Do they realize that the Expanded = true doesn't WORK!? I can't wait for this to be fixed. IT IS A BUG!
Carlos J. Quintero
on 4/17/2007 at 11:36 AM
You could try to implement a fix this way:
- For each node, use a flag that indicates if the children nodes have been retrieved or not.
- When the user expands a node, change the flag.
- When the nodes are iterated recursively, if the flag indicates that the children nodes were not retrieved previously, then retrieve them (without expanding the node!).
I know that the current behavior is by design, but it is a bad design, a lazy one, it did not happen in previous VS versions and it does not help at all, it causes problems in addins...
on 4/17/2007 at 10:57 AM
Thanks for reporting this issue. This is actually By Design since the hierarchy doesn't know about the children until the nodes are explicitly expanded.
The Visual Studio IDE Team
on 4/9/2007 at 6:24 PM
Thanks for your feedback. We have reproduced this bug on Visual Studio 2005 SP1, and we are sending this bug to the appropriate group within the VisualStudio Product Team for triage and resolution.
Visual Studio Product Team.
on 4/9/2007 at 6:03 AM
Thank you for your feedback. We are currently investigating. If this issue is urgent, please call support directly (see http://support.microsoft.com).
Visual Studio Product Team
to post a workaround.
Please enter a workaround.
© 2014 Microsoft