Programmatically determine .NET framework version
-
Saturday, October 09, 2010 10:26 PMDoes anyone know of a way to programmatically determine which version of the .NET framework is installed on a computer? I was thinking of trying to scan the registry, but my main worry is that a user would need admin rights if trying to use the method of scanning the registry.
All Replies
-
Saturday, October 09, 2010 11:04 PM
If you dont like the registry, maybe you can write code that will check for .net installation directory for the install version. Below are directories to all .net version
C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
C:\WINDOWS\Microsoft.NET\Framework\v3.0
C:\WINDOWS\Microsoft.NET\Framework\v3.5
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319kaymaf
CODE CONVERTER SITE
- Marked As Answer by Martin_XieModerator Tuesday, November 02, 2010 1:33 PM
-
Sunday, October 10, 2010 3:15 AMI don't mind using the registry, I just don't know what, if any permissions are need to read a value that is in the registry.
-
Sunday, October 10, 2010 3:54 AM
I don't mind using the registry, I just don't know what, if any permissions are need to read a value that is in the registry.
Try it and see what happen when you want to access the registrykaymaf
CODE CONVERTER SITE
-
Sunday, October 10, 2010 5:43 AM
Hello,
Can you give us any idea of what your purpose is for that, I cannot think of any.
You run a .Net program with a certain framework and cannot change that.
If there is no framework, you cannot run that.
Success
Cor -
Sunday, October 10, 2010 5:59 AM
Cor,
In case you are wondering why I'm asking for a check for the currently installed .NET version, it is because my work is making a major update to an application in a few months (we are going to use WCF as the data layer) and we need to find out which customers have installed .NET 3.5 on their computers so the updates will work for them. Currently the application is .NET 2.0.
-
Sunday, October 10, 2010 8:16 AM
I find the suggestion from Kaymaf pretty good,
Simply get the names from the IO.Directory.Info and then investigate that, should be pretty easy.
http://msdn.microsoft.com/en-us/library/system.io.directoryinfo.aspx
In fact you only have to know if that
C:\WINDOWS\Microsoft.NET\Framework\v3.5
folder exists
Success
Cor- Marked As Answer by Martin_XieModerator Tuesday, November 02, 2010 1:32 PM
-
Tuesday, October 12, 2010 7:20 AMModerator
Thank you All for your friendly help and support!
Please check the following similar cases with code samples, which provided several approaches to detect which version of .NET Framework is installed.
http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/25287435-722e-4064-862f-f9a5fa04ec73
http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/1901d1fa-da33-4377-aad3-8aacd673cafc
Detect which version of the .NET Framework is installed
Using managed code to detect what .NET Framework versions and service packs are installed - CodeProject
http://www.codeproject.com/KB/dotnet/frameworkversiondetection.aspx
Determine .NET Framework Version Via Code
Best regards,
Martin Xie
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.- Marked As Answer by Martin_XieModerator Tuesday, November 02, 2010 1:32 PM
-
Tuesday, October 12, 2010 7:33 AMModerator
For above C# code sample in some links, you can convert to VB.NET by means of some conversion tools.
1) Instant VB: C# to VB converter
http://www.tangiblesoftwaresolutions.com/Product_Details/Instant_VB.html
The tool can convert both entire C# project and C# code snippet to VB.NET.
2) Code Translation From VB.NET <-> C#
http://www.carlosag.net/Tools/CodeTranslator/
This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.

