How to Determine Wich Version of .Net is Installed ?

Using (or providing) Microsoft.NET Classes

How to Determine Wich Version of .Net is Installed ?

Postby PGilbert on Sun Aug 08, 2010 11:32 pm

When you have a commercial application using .Net that is deployed on a multitude of computers, the program should check if the proper version of .Net is installed before loading the main application. Here is what I have done with the function 'GetNetVersion' to obtain the latest version of .Net installed. Anybody got a simplier solution ?

Code: Select all
 v←GetNetVersion;DI;dir;dirs;⎕USING
 ⍝ Function to Get the Latest .Net Framework Installed on this Computer
 ⍝ Based on: http://msdn.microsoft.com/en-us/kb/kb00318785.aspx
 ⍝
 ⍝ v = Latest Version Installed
 ⍝ v = 0, When There is no Version of .Net Installed

 :Trap 0
     ⎕USING←'System' 'System.IO'
     dir←Environment.ExpandEnvironmentVariables(,⊂'%systemroot%\Microsoft.NET\Framework')
     DI←⎕NEW DirectoryInfo(,⊂dir)            ⍝ Get the DirectoryInfo Object for the Directory
     dirs←DI.GetDirectories(,⊂'v*')          ⍝ v* is the filter
     dirs←1↓¨dirs.Name                       ⍝ To remove the letter 'v' at the beginning of each directory
     v←+/¨(⊂1 0.1)ר2↑¨⊃¨(//¨'.'⎕VFI¨dirs)   ⍝ To Add the first 2 numbers of each directory
     v←1↑∪v[⍒v]                              ⍝ To order the directory names as numbers and return the highest number
 :Else
    ⍝ There is no .Net installed
     v←0
 :EndTrap


Pierre Gilbert
User avatar
PGilbert
 
Posts: 419
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: How to Determine Wich Version of .Net is Installed ?

Postby PGilbert on Sun Aug 15, 2010 2:49 pm

You can find a free program here that will show all the .Net version installed on a computer and a link to download the ones that are not. The user interface looks like this:

netversiondetector.png
netversiondetector.png (134.42 KiB) Viewed 4855 times


Pierre Gilbert
User avatar
PGilbert
 
Posts: 419
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada


Return to Microsoft.NET

Who is online

Users browsing this forum: No registered users and 1 guest