2008年至2010年的VS插件
我有一个与 Visual Studio 2008 一起使用的插件。我正在测试 2010,我看到的问题之一是该插件不再加载。
这是我用来添加插件的命令:
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)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton);
if ((command != null) && (toolsPopup != null))
{
command.AddControl(toolsPopup.CommandBar, 1);
}
}
catch (ArgumentException)
{
}
VS 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)vsCommandStatus.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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我有一个可在 2005 年和 2008 年运行的加载项(针对 .net 2.0),并且我必须不做任何更改才能使其在 2010 年运行。因此,从根本上来说,它是一个 .net 2.0 加载项可以在 2010 年工作(尽管您可能需要调整一些东西才能使其完美工作,但加载和添加命令的基本原理没有改变)
这表明这可能是一个简单的故障 - 我怀疑:
因此,我建议的第一件事是检查它是否加载正常。转到“工具”->“加载项管理器”,查看它是否已列出并选中。如果不是,那么它要么不在加载项路径上,要么您的 MyAddin.Addin 文件不正确(XML 是否已更新为 IDE 的目标版本 10.0 还是仍然显示版本 9.0?)
如果加载正常,然后您需要在调试器下运行它以查看命令未正确注册的原因。
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:
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.
有很多变化,但主要是 clr 版本发生了变化,Net 2.0 从 3.5 使用 clr 2.0。 Net 4.0 使用新的 clr,所以这很可能是
罪魁祸首
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