2008年至2010年的VS插件

发布于 2024-09-13 04:54:45 字数 885 浏览 3 评论 0原文

我有一个与 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

三五鸿雁 2024-09-20 04:54:45

我有一个可在 2005 年和 2008 年运行的加载项(针对 .net 2.0),并且我必须不做任何更改才能使其在 2010 年运行。因此,从根本上来说,它是一个 .net 2.0 加载项可以在 2010 年工作(尽管您可能需要调整一些东西才能使其完美工作,但加载和添加命令的基本原理没有改变)

这表明这可能是一个简单的故障 - 我怀疑:

  • 您的 .Addin 文件有问题,或者它不在 VS2010 加载项路径上,因此 VS2010 没有加载它,或者
  • 加载项正在加载,但未成功添加其命令。

因此,我建议的第一件事是检查它是否加载正常。转到“工具”->“加载项管理器”,查看它是否已列出并选中。如果不是,那么它要么不在加载项路径上,要么您的 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:

  • 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.

无言温柔 2024-09-20 04:54:45

有很多变化,但主要是 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文