I want to be able to create a Visual Studio add-in with a number of commands. In the addin’s OnConnection method the wizard generates this boilerplate:
Command command = commands.AddNamedCommand2(_addInInstance, "MyAddin", "MyAddin",
"Executes the command for MyAddin", true, 59, ref contextGUIDS, ... )
This creates a single command for MyAddin on the Tools menu, but any attempt I make to create further commands are ignored:
Command command = commands.AddNamedCommand2(_addInInstance, "MyAddin command2", "MyAddin command2",
"Executes the command for MyAddin command 2", true, 59, ref contextGUIDS, ... )
Is this a restriction of Addins themselves, that they can only correspond to a single menu item? Or does it have to be done in a different way? Should I be writing a VSPackage instead?
I found that you aren’t in fact limited to creating a single command in an AddIn. The problem turned out to be that the command names can’t have spaces in them as I had in the above example. In the
Connectmethod of my addin I’ve now got a loop that iterates over a list of commands, adding them to the application’s command list and adding a newCommandBarfor them: