473,326 Members | 2,655 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,326 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 8658
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.