VS plugin from 2008 to 2010
I have a plug-in that I use with Visual Studio 2008. I am testing 2010 and one of the problems I am seeing is the fact that the plug-in doesn't get loaded anymore.
This is the command I am using to add my plug-in:toolsMenuName = "Tools";
Microsoft.VisualStudio.CommandBars.CommandBar menuBarCommandBar = ((CommandBars)_applicationObject.CommandBars)["MenuBar"];
CommandBarControl toolsControl = menuBarCommandBar.Controls[toolsMenuName];
var toolsPopup = (CommandBarPopup)toolsControl;
try
{
Command command = commands.AddNamedCommand2(_addInInstance, "TestData", "Test Data", "", true, 0, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommand开发者_StackOverflowStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton);
if ((command != null) && (toolsPopup != null))
{
command.AddControl(toolsPopup.CommandBar, 1);
}
}
catch (ArgumentException)
{
}
What has changed in VS 2010?
Thanks Tony
I have an add-in that works in 2005 and 2008 (targetting .net 2.0), and I had to make no changes to get it working in 2010. So, fundamentally a .net 2.0 add-in can work in 2010 (although you may need to tweak a few things to make it work perfectly, the fundamentals of loading and adding a command haven't changed)
This suggests that it's probably a simple glitch - I'd suspect:
- There is something wrong in your .Addin file, or it is not on the VS2010 add-ins path, so it is not being loaded by VS2010, or
- The add-in is loading, but is not adding its commands successfully.
The first thing I would suggest is therefore to check if it is loading ok. Go to Tools->Add-In Manager and see if it is listed and checked. If not, then it's either not on the add-ins path, or your MyAddin.Addin file isn't correct (has the XML been updated to target version 10.0 of the IDE or is it still saying version 9.0?)
If it's loading ok, then you need to run it under a debugger to see why your command isn't registering correctly.
A lot has changed but mainly the clr version has changed, Net 2.0 from 3.5 use clr 2.0. Net 4.0 uses the new clr, so chances are this is the culprit
Regards
精彩评论