制作 Visual Studio 插件时如何实现 IVsStatusbar [英] How to implement IVsStatusbar when making a Visual Studio Add-In

查看:26
本文介绍了制作 Visual Studio 插件时如何实现 IVsStatusbar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个 Visual Studio 加载项,我需要做的一件事就是与状态栏交互.根据 MSN:状态栏应该是一个相当简单的过程.但是,我无法在 IVsStatusbar 对象上正确解析它.

I am trying to create a visual studio add-in, and one of the things I will need to do is interact with the status bar. According to MSN: Status Bar it should be a fairly straightforward process. However, I cannot get it to resolve properly on the IVsStatusbar object.

该示例建议遵循一个非常标准的流程,例如:

The example suggests following a pretty standard process such as:

    IVsStatusbar StatusBar = (IVsStatusbar)GetService(typeof(SVsStatusbar));

但 Visual Studio 不会解析引用并告诉我 IVsStatusbar 不存在.如果我右键单击自动解析,它只会告诉我为它生成一个新类.

But Visual Studio will not resolve the reference and tells me IVsStatusbar does not exist. If I right-click to auto-resolve, it will just tell me to generate a new class for it.

我知道它需要我添加的 Microsoft.VisualStudio.Shell.Interop,但仍然没有运气.我已经尝试过 dll 的 v 10.0 和 v 11.0,但都没有工作.它是否不再存在于命名空间中?或者我应该使用另一个引用/对象吗?

I know it requires Microsoft.VisualStudio.Shell.Interop which I added, but still no luck. I have tried v 10.0 and v 11.0 of the dll, but neither have worked. Does it no longer exist in the namespace? Or is there another reference / object I should be using?

我应该有我需要的所有参考资料:

I should have all of the references I need:

    using System;
    using Extensibility;
    using EnvDTE;
    using EnvDTE80;
    using Microsoft.VisualStudio.CommandBars;
    using Microsoft.VisualStudio.Shell.Interop;
    using System.Resources;
    using System.Reflection;
    using System.Globalization;
    using Microsoft.VisualStudio.Shell;

推荐答案

您需要引用 Microsoft.VisualStudio.Shell.Interop.xx.dll 的所有版本,而不仅仅是其中之一.他们不会随着时间的推移更改接口,而是创建一个新的程序集,其中添加接口,这些接口是服务在先前版本之外实现的.

You need to reference all of the versions of Microsoft.VisualStudio.Shell.Interop.xx.dll, not just one of them. Rather than change interfaces over time, they create a new assembly with added interfaces which the services implement in addition to the previous versions.

请注意,这仅适用于互操作程序集.对于其他程序集,例如 Microsoft.VisualStudio.Shell,您只需引用 10.0 版(适用于 Visual Studio 2010 或 2010+2012 扩展)或 11.0 版(适用于仅适用于 Visual Studio 2012 的扩展).

Note that this only applies to the Interop assemblies. For other assemblies, such as Microsoft.VisualStudio.Shell, you only need to reference version 10.0 (for a Visual Studio 2010 or 2010+2012 extension) or version 11.0 (for a Visual Studio 2012-only extension).

这篇关于制作 Visual Studio 插件时如何实现 IVsStatusbar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆