【问题标题】:Visual Studio 2013 C# The type or namespace name IVSStatusBar could not be foundVisual Studio 2013 C# 找不到类型或命名空间名称 IVSStatusBar
【发布时间】:2015-03-31 17:45:55
【问题描述】:

我正在尝试将状态栏添加到已经运行的应用程序。我正在使用 Visual Studio 13、WPF、C#。

public void SetStatusBar(string text) { IVsStatusbar statusBar = (IVsStatusbar)GetService(typeof(SVsStatusbar)); }

我收到以下错误: 找不到类型或命名空间名称“IVsStatusbar”(您是否缺少 using 指令或程序集引用?) 当前上下文中不存在名称“GetService” 以及“SVsStatusbar”的第一条消息

我有最新的 SDK。我的使用语句是:

using System
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using GemBox.Spreadsheet;

我错过了什么?这应该不难找到。

【问题讨论】:

  • 您可能缺少对 Microsoft.VisualStudio.Shell.Interop 的引用。
  • IVSStatusBar 是在程序集 Microsoft.VisualStudio.Shell.Interop.dll 的命名空间 Microsoft.VisualStudio.Shell.Interop 中定义的 the interface。并且 1)我在您的 using 指令中没有看到这个命名空间 2)包含它的程序集在标准 WPF 项目模板中可能是 referenced by default
  • 这里有一些附加信息:stackoverflow.com/questions/16678056/…

标签: c# wpf visual-studio-2013 statusbar


【解决方案1】:

你需要使用Microsoft.VisualStudio.Shell.Interop

MSDN article 应该提供您可能需要的更多信息。

【讨论】:

  • 在发布之前我已经尝试过了。对不起,我应该提到它。当我输入 using 和 Microsoft 时,VisualStudio 没有智能感知。我无法通过使用添加它。我重新下载了SDK,还是没有出现。
  • 好的,我想通了。我需要单击参考,添加参考,选择扩展并将其添加到那里。然后,我可以用“使用”来声明它。
【解决方案2】:

IVsStatusBar 定义在Microsoft.VisualStudio.Shell.Interop.dll 添加这个命名空间。

请参考本页How to implement IVsStatusbar when making a Visual Studio Add-In

【讨论】:

  • 我最初使用的是那个页面。我没有 Microsoft.VisualStudio.Shell.Interop。我在 Microsoft 的网站上找不到如何安装此组件。
  • 你是什么意思你找不到。您需要添加(Interop.dll)对项目的引用并将其添加到代码中的命名空间
猜你喜欢
  • 2021-07-17
  • 1970-01-01
  • 2013-03-25
  • 1970-01-01
  • 2011-06-28
  • 1970-01-01
  • 2021-08-19
  • 1970-01-01
  • 2017-07-12
相关资源
最近更新 更多