473,405 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

How to get .NET version programmatically?

Hi,

Is there a programmatic way to get the "general" or "overall" version of a
currently running instance of the Visual Studio .NET compiler? What I mean
by "general" or "overall" version is, I want to programmatically get the
version string that I see in the registry underneath the
HKLM\SOFTWARE\Microsoft\VisualStudio key, such as "7.0" or "7.1" (for .NET
2002 or .NET 2003, respectively). My registry contains both 7.0 and 7.1
keys, so I want to know which one I'm currently running. Note that I am not
interested in getting the CLR version (that is, the version that is returned
by the GetCORVersion() call).

Thanks!
--
Whitney Kew
Software Engineer
Rain Bird Corporation
http://rainbird.com
Jul 21 '05 #1
4 8661
What is someone has both 2002 and 2003 installed side-by-side?

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph

Whitney Kew wrote:
Hi,

Is there a programmatic way to get the "general" or "overall" version of a
currently running instance of the Visual Studio .NET compiler? What I mean
by "general" or "overall" version is, I want to programmatically get the
version string that I see in the registry underneath the
HKLM\SOFTWARE\Microsoft\VisualStudio key, such as "7.0" or "7.1" (for .NET
2002 or .NET 2003, respectively). My registry contains both 7.0 and 7.1
keys, so I want to know which one I'm currently running. Note that I am not
interested in getting the CLR version (that is, the version that is returned
by the GetCORVersion() call).

Thanks!

Jul 21 '05 #2
Your question is a bit intriguing, because:

- At coding time, you know which VS.NET version you are using.

- At run-time, the executable can be running with .NET Framework 1.0 or 1.1,
depending on its configuration and the .NET Version on the target machine,
but it seems that you are not interested in the .NET Framework version
(returned by System.Environment.Version() )

The only relationship of the running executable with VS.NET is that maybe it
has attached the VS.NET debugger: your code can guess if it is beeing
debugged through System.Diagnostics.Debugger.IsAttached(), but I think that
you can not know which the debugger is.

So, although the goal of your question is beyond me, the only way that I can
think is guessing the running VS.NET through indirect ways, assuming that
you don´t have VS.NET 2002 and 2003 running side by side. For example:

- You can get the processes with the name "devenv.exe" and from there try to
get the path to the file and its version.

- You can get if there are COM objects running with the ProgIDs
"VisualStudio.DTE.7" (VS.NET 2002) or "VisualStudio.DTE.7.1" (VS.NET 2003).
In VB6 you would use the GetObject("MyProgID") function.

--

Carlos J. Quintero (Visual Developer - .NET MVP)

FAQs, Knowledge Base, Files, Docs, Articles, Utilities, etc. for .NET
addins:
http://groups.yahoo.com/group/vsnetaddin/ (free join)


"Whitney Kew" <Wh********@discussions.microsoft.com> escribió en el mensaje
news:FD**********************************@microsof t.com...
Hi,

Is there a programmatic way to get the "general" or "overall" version of a
currently running instance of the Visual Studio .NET compiler? What I mean by "general" or "overall" version is, I want to programmatically get the
version string that I see in the registry underneath the
HKLM\SOFTWARE\Microsoft\VisualStudio key, such as "7.0" or "7.1" (for .NET
2002 or .NET 2003, respectively). My registry contains both 7.0 and 7.1
keys, so I want to know which one I'm currently running. Note that I am not interested in getting the CLR version (that is, the version that is returned by the GetCORVersion() call).

Thanks!
--
Whitney Kew
Software Engineer
Rain Bird Corporation
http://rainbird.com

Jul 21 '05 #3
Hi Carlos,

Thanks for the quick reply! Actually, it's a Custom Tool that runs during a
build. Its "Register for COM Interop" property is set to True, and it has
functions utilizing the [ComRegisterFunction] and [ComUnregisterFunction]
attributes that register and unregister the tool as a custom code generator
with the current version of .NET. Thus, I want the tool to be able to detect
which version of the compiler is being used when the build is occurring, so
that it knows with which .NET version to register before it runs. I
appreciate your solution about getting the file version of the current
running instance of devenv.exe, and that would probably work for us, but I'd
be surprised if there isn't another, more .NET-centric way of getting the
"7.0" or "7.1" strings. Any thoughts?

Whitney Kew

"Carlos J. Quintero [MVP]" wrote:
Your question is a bit intriguing, because:

- At coding time, you know which VS.NET version you are using.

- At run-time, the executable can be running with .NET Framework 1.0 or 1.1,
depending on its configuration and the .NET Version on the target machine,
but it seems that you are not interested in the .NET Framework version
(returned by System.Environment.Version() )

The only relationship of the running executable with VS.NET is that maybe it
has attached the VS.NET debugger: your code can guess if it is beeing
debugged through System.Diagnostics.Debugger.IsAttached(), but I think that
you can not know which the debugger is.

So, although the goal of your question is beyond me, the only way that I can
think is guessing the running VS.NET through indirect ways, assuming that
you don´t have VS.NET 2002 and 2003 running side by side. For example:

- You can get the processes with the name "devenv.exe" and from there try to
get the path to the file and its version.

- You can get if there are COM objects running with the ProgIDs
"VisualStudio.DTE.7" (VS.NET 2002) or "VisualStudio.DTE.7.1" (VS.NET 2003).
In VB6 you would use the GetObject("MyProgID") function.

--

Carlos J. Quintero (Visual Developer - .NET MVP)

FAQs, Knowledge Base, Files, Docs, Articles, Utilities, etc. for .NET
addins:
http://groups.yahoo.com/group/vsnetaddin/ (free join)


"Whitney Kew" <Wh********@discussions.microsoft.com> escribió en el mensaje
news:FD**********************************@microsof t.com...
Hi,

Is there a programmatic way to get the "general" or "overall" version of a
currently running instance of the Visual Studio .NET compiler? What I

mean
by "general" or "overall" version is, I want to programmatically get the
version string that I see in the registry underneath the
HKLM\SOFTWARE\Microsoft\VisualStudio key, such as "7.0" or "7.1" (for .NET
2002 or .NET 2003, respectively). My registry contains both 7.0 and 7.1
keys, so I want to know which one I'm currently running. Note that I am

not
interested in getting the CLR version (that is, the version that is

returned
by the GetCORVersion() call).

Thanks!
--
Whitney Kew
Software Engineer
Rain Bird Corporation
http://rainbird.com


Jul 21 '05 #4
2 more thoughts:

- That kind of things (pre/post build actions) can be done with .NET
add-ins, which offer a direct way of getting the .NET version where they are
hosted (DTE.Version, DTE.Edition, etc.)

- If you are using a custom tool, external to VS.NET, I think that the only
way is to guess the running devenv.exe and get its version as I told you, or
pass the version to the custom tool somehow: for example, external tools can
receive the Solution and Project file names, and since the internal format
of those files is different in 7.0 and 7.1, parsing them you can guess the
target IDE. By the way, how do you call the custom tool when a build is
performed?
--

Carlos J. Quintero (Visual Developer - .NET MVP)

FAQs, Knowledge Base, Files, Docs, Articles, Utilities, etc. for .NET
addins:
http://groups.yahoo.com/group/vsnetaddin/ (free join)

"Whitney Kew" <Wh********@discussions.microsoft.com> escribió en el mensaje
news:D8**********************************@microsof t.com...
Hi Carlos,

Thanks for the quick reply! Actually, it's a Custom Tool that runs during a build. Its "Register for COM Interop" property is set to True, and it has
functions utilizing the [ComRegisterFunction] and [ComUnregisterFunction]
attributes that register and unregister the tool as a custom code generator with the current version of .NET. Thus, I want the tool to be able to detect which version of the compiler is being used when the build is occurring, so that it knows with which .NET version to register before it runs. I
appreciate your solution about getting the file version of the current
running instance of devenv.exe, and that would probably work for us, but I'd be surprised if there isn't another, more .NET-centric way of getting the
"7.0" or "7.1" strings. Any thoughts?

Whitney Kew

Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Michael Kellogg | last post by:
At the beginning of program execution, I want to compare the executing version of the program against the network copy to see if there's been an update. In the "Properties" window of an EXE, I can...
3
by: Nadav | last post by:
Hi, I have a collection of files needed their version to be set, This should be done programmatically, I wonder... is there any existing API that enable modification/addition of version to an...
2
by: Scott | last post by:
Does anyone know of a way to get the .NET Framework version that's required by a specified assembly. I have a program I've written that creates a Windows Installer setup for any application....
4
by: Whitney Kew | last post by:
Hi, Is there a programmatic way to get the "general" or "overall" version of a currently running instance of the Visual Studio .NET compiler? What I mean by "general" or "overall" version is, I...
3
by: Shadow Lynx | last post by:
At the bottom of the default Error page that appears when Unhandled Exceptions occur, what exactly is the difference between the "Microsoft ..Net Framework Version" and the "ASP.NET Version"? I...
0
by: Simon Verona | last post by:
My application autoupgrades itself by uploading an msi file from the server and then executing it, immediately terminating to let the installation script run. The problem I have is that...
8
by: schaf | last post by:
Hi Ng! My application (version 1 a1) communicates with a service (version 1 s1). Now I would like to update the service and create a service version 2 (s2). The new function calls within s2 are...
29
by: =?Utf-8?B?SGVybWF3aWg=?= | last post by:
Hello, Please anybody help me. I have only a little experience with web development. I created simple project using ASP NET 2.0 (VS 2005) It works fine on local computer. When I tried to run...
3
by: xke | last post by:
How can I find out the version of a DLL, if it was done with VS2005 or VS2003?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.