Thursday, February 23, 2012

Visual Studio Addin loading but not showing in the Tools menu

Once you have created an Addin and have the addin and the dll files, moving them to the Visual Studio's Addins folder is not enough. There is a small catch, if you developed the addin on the same machine. In this case your addin probably was already set up with VS with the location where you developed the addin and by simply copying the addin to the VS' Addins folder is not enough.

VS maintains a PreloadAddinStateManaged registry key. There is an entry that relates your addin's class with its assembly path.

MyCoolAddin.Connect;C:\users\John\Documents\Visual Studio 2010\Addins\MyCoolAddin - For Testing.Addin

Now, if you rename your addin to something that makes more sense, like just MyCoolAddin.Addin (without the " - For Testing" part that VS adds just for... testing), it won't work.

The explanation is that the ext_cm_UISetup is sent only the first time the addin is loaded. And the code generated by the addin wizzard creates the Tool menu item exactly in this ext_cm_UISetup.

The solution is to run:

devenv /ResetAddin MyCoolAddin.Connect

and the put your MyCoolAddin.Addin and MyCoolAddin.dll in a folder where VS searches for Addins. (Btw, you can see these foloders in VS in Tools > Options > Environment > Add-in/Macro Security).

No comments:

Post a Comment