Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
610 views
in Technique[技术] by (71.8m points)

.net - Detect the Visual Studio version inside a VSPackage

How can I check/detect which Visual Studio version is running under my VSPackage?

I cannot get from the registry because the computer could have several versions installed, so I guess there is an API that is able to get it.

Anybody knows how to get it from a managed Visual Studio package using C#?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You could try to get version via automation DTE object. In MPF you could get it in this way:

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

There are some other related things to retrieve DTE object - via Project.DTE, also read this thread if you're getting null for DTE.

Then you can get the version by using DTE.Version property.

Also useful information could be found on Carlos Quintero (VS addin ninja) website HOWTO: Detect installed Visual Studio editions, packages or service packs


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...