I have been struggling during the last weeks to get 32×32 icons from Office 2007 and yesterday I found the 2007 Office System Add-In: Icons Gallery. Also, a question that appears from time to time in the forums is how to get the numerical indexes of the Office bitmaps to use when calling the AddNamedCommand method, and incredible as it is, I think that Microsoft never documented this for that method in MSDN, and there used to be years ago an Excel spreadsheet (quite difficult to find then, and impossible nowadays, likely removed from MSDN) to help in the task with VB5/VB6/Office add-ins. Fortunately I put a copy in the Files section of the Yahoo forum for VS.NET add-ins that I used to visit until a couple of years ago before moving to the MSDN forum, and I had a copy of the Excel file in my own hard disk. I have documented all this in my latest article:
Visual Studio allows a rich customization of its user interface and, alas, it can affect your add-in. This new article of mine examines some common customization scenarios and how your add-in can handle them more or less gracefully:
Traditionally the VSLangProjXX.dll files contain interfaces such as VBProjectPropertiesX, CSharpProjectConfigurationPropertiesY and VSLangProj90.dll contains them but it seems that it was forgotten to add properties to them:
I have been struggling during the last day to get a list of actual project type Guids (EnvDTE.Project.Kind property), since not all the Guids that appear in the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\<version>\Projects registry key are actual project type Guids that appear in project or solution files. Here is the result list:
As you may know if you are a C# add-in programmer, DTE events can get disconnected if you don’t hold a class variable pointing to them (VB.NET add-in programmers tend to use the WithEvents approach which already uses a class variable so they don’t suffer this problem). Although this issue is well documented in MSDN, FAQs, blogs, and an article of mine, etc., it was not clear yet for some people why a garbage collection happened if VS holds a reference to the object raising the events. So, I have updated the article to explain it more clearly:
Today I had to get the target .NET Framework of a VS 2008 project. While the project file stores the values as “v2.0”, “v3.0”, etc, the values returned by the automation model are a bit surprising at first glance. Here is the article that I wrote about this:
Another “task” that can be quite usual from a Visual Studio add-in is to add a task to the Task List or Error List. It happens in Visual Studio 2005/2008 that it is not as easy as it seems because of the following:
VS 2005/2008 uses a separate Error List window for errors, and the automation model (EnvDTE) doesn’t provide a way to add errors, you need to implement an error provider for that (typically compilers implement an error provider). So, you can only add items to the Task List, not to the Error List.
While a Task Item has properties for a file and line number, when you double click it VS doesn’t navigate to that file and line number unless you have used the EnvDTE80.TaskItems2.Add2 method.
When an add-in (or macro) adds a task, it is added to a new item in the combobox of the Task List with the name “Add-ins and macros”, instead of, say, the “User Tasks” item. So you need to filter the combobox by that provider, but, alas, this is very tricky. Chetan Chudasama, from the Visual Studio team, published how to do it in its Programmatically setting TaskList view blog post. He didn’t mention where the numbers such as 2200 come from, so wrote a HOWTO: Execute a command by Guid and Id from a Visual Studio add-in post explaining it.
While most Visual Studio commands have a name and you can execute them using DTE.ExecuteCommand, there are cases where commands don’t have a name, just the Guid and Id that truly identifies them, For example, the command to filter the Task List of Visual Studio 2005/2008 by its combobox (my next article will be about this). This article explains how to get the Guids and IDs of Visual Studio commands, and how to execute a command from the automation model (EnvDTE) given its Guid and Id:
A quite simple question (once you know the answer) is how to open the Web Browser of Visual Studio and navigate to some web site or page. I thought that the automation model didn’t provide such capability and was about to use a workaround, but it happens that it provides a method to do it. Just in case you weren’t aware of it, here it is:
When I searched just “MZ-Tools” on Google some time ago I noticed one of the first results in the second page: Making MZTools for VBA work on Vista and it was amazing to me that some user went as far as finding a way to make an old version of my MZ-Tools add-in for VBA work on Windows Vista and publish a blog post with screenshots of what you needed to tweak that now seems quite popular. Of course I was aware of this problem and I fixed it some months before, so he could have downloaded a new version. But anyway, this illustrates a point: if you don’t take the proper design decisions, an add-in that worked fine on Windows XP (as long as you were administrator), it may not work on Windows Vista because by default even administrators don’t have administrator rights (which although it’s a culture change is a good thing IMHO). My latest article explains some design decisions that you must take into account for your installer (installation time) and your add-in (run time):