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#?
Finally I wrote a class to detect the Visual Studio version. Tested and working:
You could try to get version via automation DTE object. In MPF you could get it in this way:
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
I think the following code is better: