Question

When a solution is programmatically opened in an add-in/extension (VS2012 in my case) using Solution.Open, the solution file is not added to the projects MRU (i.e. File->Recent Projects and Solutions menu) as it would be if you opened the solution using the File->Open->Project/Solution menu. Is there a way to force the file to be added? I've seen some references to manipulating the registry (e.g. HKCU\Software\Microsoft\VisualStudio\11.0\ProjectMRUList) but is there another way that doesn't assume the storage that VS uses and therefore would be less likely to break in the future? Perhaps a VS interface that might take care of it regardless of where the info might be stored. That would also allow me to ignore what the max # of mru items, avoiding errors in updating/re-numbering the existing items, etc. I found the IVsMRUItemsStore but if that is what I should use I'm unsure about what categoryGuid I would be using. From what I've seen it seems like this interface might be related to built in search functionality.

[Edit] Ok I've done some more digging. First, IVsMRUItemsStore seems unrelated to the project mru list since the Microsoft.VisualStudio.PlatformUI.MRUItemsStoreService seems to be empty even after showing the recent projects menu. Second, I've tried directly manipulating the registry but that doesn't work out well because VS doesn't know about the registry change and so the menu and its internal cache remain unchanged. If you subsequently open another project or solution using the Open Project dialog, the registry gets overwritten with the cached information plus the project/solution opened via the dialog. I would be ok with manipulating the registry if there was some way of notifying VS to re-read the registry info (without closing VS). I would also be happy if there were some other programmatic way of manipulating the recent projects list through VS' object model.

[Edit2] I've found that the View menu item in TFS' Source Control Explorer does exactly what I want. It will open a given solution, prompting if the solution needs to be converted (without closing the open documents) and adds the item to the MRU. The question now is how do I do the same thing in my extension/addin? I can't use their command (unless it takes a parameter) because the solution/project I'm opening is not in TFS.

Was it helpful?

Solution

The TFS Source Control Explorer is simply calling IVsSolution.OpenSolutionFile, which adds the solution to the recent file lists. I suspect all you'll have to do is just use that instead of the EnvDTE method and you'll be good to go.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top