检测Visual Studio版本 [英] Detecting Visual studio edition

查看:117
本文介绍了检测Visual Studio版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要检测哪个版本的Visual Studio在通过IDE运行时运行我的项目。通过使用我想找出MyDocuments中visual studio的路径,如:

C: \ Users\xxx\Documents\Visual Studio 2012





是否有任何C#方法可以帮助我使用VS2012?





提前致谢

I need to detect which version of Visual studio is running my project when it is running through IDE , By using that I want to find out the path of visual studio in MyDocuments like:
C:\Users\xxx\Documents\Visual Studio 2012


Is there any C# method that can help me using VS2012?


Thanks in advance

推荐答案

如果您的项目是Visual Studio扩展,您可以使用DTE.Edition。



如果没有,您的代码无法确定,也不应该真正关心哪个版本的Visual Studio调试器附加到您的代码。
If your project is a Visual Studio extension, you can use DTE.Edition.

If not, there is no way for your code to determine, nor should it really care about, which version of the Visual Studio debugger is attached to your code.


Application类的这个属性将返回Visual Studio路径,无论它在PC上的什么位置。
This property of the Application Class will return the Visual Studio path wherever it is on the PC.
Application.StartupPath

在我的电脑上,它返回:

On my PC, this returns:

C:\Users\<MyUserName>\Documents\Visual Studio 2012\Projects\<MySolutionName>\<MyProjectName>\bin



您可以从中提取Visual Studio的路径返回的值。无论是否覆盖默认安装路径,这都有效。


You can extract the path to Visual Studio from the returned value. This works whether or not the default installation path was overridden or not.


这篇关于检测Visual Studio版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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