none
How to find out whether .Net Framework 3.5 is put to on or off in Windows 7 from an installer (VS 2008) RRS feed

  • Question

  • Hi,

    I have a requirement in which i need to find whether .Net Framework 3.5 is installed in the machine. Only if the .Net 3.5 installed then the installer should run else it should display a message stating .Net 3.5 required.

    I have done this senario in Windows Xp and Server 2003 using the below code.

    ApplicationRegDisplay="Microsoft .NET Framework 3.5";
    
    internal static bool CheckApplicationInstalled(string ApplicationRegDisplay, 
        bool DotNetCheck)
    {
        bool _AppInstalled = false;
        RegistryKey oLocalMachine = Registry.LocalMachine;
        RegistryKey rKyUninstall = oLocalMachine.OpenSubKey(
            "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall");
        string[] subkeys = rKyUninstall.GetSubKeyNames();
        foreach (string subkey in subkeys)
        { 
            RegistryKey rKyUninstallSubKey = rKyUninstall.OpenSubKey(subkey);
            object DispText = rKyUninstallSubKey.GetValue("DisplayName");
            string sDispText = "";
            if (DispText == null)
                DispText = "";
            sDispText = (string)DispText;
            if (DotNetCheck)
            {
                if (sDispText.ToUpper().Contains(ApplicationRegDisplay.ToUpper()))
                {
                    _AppInstalled = true;
                    Globals.IsDotNet35Installed = true;
                    break;
                }
            }
            else
            {
                if (string.Compare(ApplicationRegDisplay, sDispText, true) == 0) 
                {
                    _AppInstalled = true;
                    break;
                }
            }
        }
        return _AppInstalled;
    }

    It is workin fine in both xp and 2K3 but was not workin on Windows 7 even if i enabled .Net 3.5 in the "Turn windows feature on or off".

    Please help me out of this.

    I hope the windows 7 have a different HKey to find out whether .Net 3.5 is enabled or disabled.

    Thanks in advance.

    Thanks & Regards,
    Akhil

     


    Akhil.N.P
    Monday, January 25, 2010 9:17 AM

Answers

All replies