.net - 检测 VSPackage 中的 Visual Studio 版本

标签 .net visual-studio vsix vspackage vs-extensibility

如何检查/检测在我的 VSPackage 下运行的 Visual Studio 版本?

我无法从注册表中获取,因为计算机可能安装了多个版本,所以我猜有一个 API 可以获取它。

有人知道如何使用 C# 从托管的 Visual Studio 包中获取它吗?

最佳答案

您可以尝试获取版本 通过自动化 DTE 对象 .在强积金中,您可以通过以下方式获得:

EnvDTE.DTE dte = (EnvDTE.DTE)Package.GetGlobalService(typeof(EnvDTE.DTE));

还有一些其他相关的东西来检索 DTE 对象 - 通过 Project.DTE ,另请阅读 this thread如果 DTE 为空。

然后您可以使用 DTE.Version property 获取版本.

在 Carlos Quintero (VS addin ninja) 网站 HOWTO: Detect installed Visual Studio editions, packages or service packs 上也可以找到有用的信息。

关于.net - 检测 VSPackage 中的 Visual Studio 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11082436/

相关文章:

.net - wsdl.exe 错误 : Unable to import binding '...' from namespace '...'

c# - 在以下代码中获取 'Stream does not support writing.' 异常

.net - Image.Horizo​​ntalResolution 和 Image.VerticalResolution - 为什么 float ?

c++ - 代码在尝试打开 QDialog 时卡住

.net - 什么是 Visual Studio 中引用属性的别名?

visual-studio-2015 - VSIX 安装程序 : SignatureDescription could not be created for the signature algorithm supplied

.net - 无法启动 vsixinstaller.exe,VSIX 安装程序进程失败,退出代码 1006

c# - 如何管理内存有限的网格中显示的数百万行

windows - 用于 Windows 的 OpenAcc

c# - 在我在 Visual Studio 2017 中生成的文件中添加 "Generated"关键字