checking for .net framework 3.5

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lttan123
    New Member
    • Oct 2008
    • 11

    checking for .net framework 3.5

    How to detect whether the machine have .Net Framework 3.5 install
    from framework 2.0
  • MrMancunian
    Recognized Expert Contributor
    • Jul 2008
    • 569

    #2
    You can see that in the Add/Remove Programs control panel...

    Steven

    Comment

    • lttan123
      New Member
      • Oct 2008
      • 11

      #3
      I mean doing it programatically from vb.net for example.

      Comment

      • MrMancunian
        Recognized Expert Contributor
        • Jul 2008
        • 569

        #4
        Originally posted by lttan123
        I mean doing it programatically from vb.net for example.
        I knew that, but you didn't ask for that...

        A quick search on Google gave me this URL:

        http://www.dotnetspide r.com/resources/20834-Check-Dot-Net-Version-Installed-PC.aspx

        It's in C#, but easy enough to translate to VB.NET.

        Steven

        Comment

        • bkreitman
          New Member
          • Oct 2008
          • 5

          #5
          // A couple of quick methods to search the registry
          // and check the "installed" status for each Framework on the system,



          Code:
                  public static ICollection<Version> GetInstalled_DotNet_Versions() {
          
                      List<Version> installedVersions = new List<Version>();
          
                      string componentsKeyName = @"SOFTWARE\Microsoft\NET Framework Setup\NDP";
                      string version;
                      int installedFlag;
          
                      try {
                          Microsoft.Win32.RegistryKey componentsKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(componentsKeyName);
                          string[] subkeys = componentsKey.GetSubKeyNames();
          
                          foreach (string skey in subkeys) {
                              Microsoft.Win32.RegistryKey key = componentsKey.OpenSubKey(skey);
          
                              // Let's try to get any version information that's available 
                              version = (string)key.GetValue("Version");
                              installedFlag = (int)key.GetValue("Install");
          
                              if (installedFlag > 0)
                                  installedVersions.Add(new Version(version));
                          }
                      }
                      catch (Exception e) {
                      }
          
                      return installedVersions;
                  }
          
                  public static string GetMaxInstalled_DotNet_Version() {
                      ICollection<Version> versions = GetInstalled_DotNet_Versions();
                      Version maxVersion = new Version();
                      foreach (Version v in versions) {
                          if (v.CompareTo(maxVersion) > 0)
                              maxVersion = v;
                      }
                      return maxVersion.ToString();
                  }
          Last edited by Curtis Rutland; Oct 23 '08, 03:25 PM. Reason: Added Code Tags - Please surround your code with [CODE] and [/CODE]

          Comment

          Working...