473,657 Members | 2,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get .NET version programmaticall y?

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 programmaticall y get the
version string that I see in the registry underneath the
HKLM\SOFTWARE\M icrosoft\Visual Studio 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 8694
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 programmaticall y get the
version string that I see in the registry underneath the
HKLM\SOFTWARE\M icrosoft\Visual Studio 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.Environm ent.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.Diagnost ics.Debugger.Is Attached(), 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.D TE.7" (VS.NET 2002) or "VisualStudio.D TE.7.1" (VS.NET 2003).
In VB6 you would use the GetObject("MyPr ogID") 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********@dis cussions.micros oft.com> escribió en el mensaje
news:FD******** *************** ***********@mic rosoft.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 programmaticall y get the
version string that I see in the registry underneath the
HKLM\SOFTWARE\M icrosoft\Visual Studio 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 [ComRegisterFunc tion] and [ComUnregisterFu nction]
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.Environm ent.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.Diagnost ics.Debugger.Is Attached(), 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.D TE.7" (VS.NET 2002) or "VisualStudio.D TE.7.1" (VS.NET 2003).
In VB6 you would use the GetObject("MyPr ogID") 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********@dis cussions.micros oft.com> escribió en el mensaje
news:FD******** *************** ***********@mic rosoft.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 programmaticall y get the
version string that I see in the registry underneath the
HKLM\SOFTWARE\M icrosoft\Visual Studio 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********@dis cussions.micros oft.com> escribió en el mensaje
news:D8******** *************** ***********@mic rosoft.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 [ComRegisterFunc tion] and [ComUnregisterFu nction]
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
1568
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 see the version there, but cannot figure out how to get the version out programmatically. Anyone know how I can do this? Or am I better off just comparing versus the creation date of a file or something? -- Michael
3
1407
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 existing binary? It is possible to parse the '.rsrc' section manually, however, I am trying to avoid this, any samples, pointers or advice would be appreciated. -- Nadav
2
4724
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. However, for many of the programs I work with there are a lot of files that have come from other developers, and I'd like to be able to determine programmatically which version of the Framework is required by each assembly. This way I'll know which...
4
429
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 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,...
3
3060
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 understand that the ASP.Net version is the version of ASP.Net that the current site is running under and it can be retreived with System.Environment.Version.ToString. What exactly is the Microsoft .NET Framework Version that is displayed? It is...
0
1002
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 sometimes, the download to the server hasn't completed and the pc then tries to run the msi which is the same version as that installed already which gives an annoying error message... Is there any way that I can programmatically check the software...
8
3499
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 implemented in a new interface, which derive from the old one to ensure that an old version of my application (a1) still works with s2. If i run my new version of the application a2 with s1 I get a InvalidCastException (Return argument has an...
29
2476
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 the application on the web, it give me an error about net framework version information.
3
9269
by: xke | last post by:
How can I find out the version of a DLL, if it was done with VS2005 or VS2003?
0
8739
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8513
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8613
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7351
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5638
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2740
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.