Exemplo n.º 1
0
        internal static bool IsDotNetFrameworkVersionInstalled(Version requiredVersion)
        {
            int num;
            int num2;
            int num3;

            if (FrameworkRegistryInstallation.CanCheckFrameworkInstallation(requiredVersion, out num, out num2, out num3))
            {
                return(FrameworkRegistryInstallation.IsFrameworkInstalled(num, num2, num3));
            }
            return(FileSystemIsDotNetFrameworkVersionInstalled(requiredVersion));
        }
Exemplo n.º 2
0
            /// <summary>
            /// Check if the given version if the framework is installed
            /// </summary>
            /// <param name="majorVersion">Major version of .NET required, for .NET 3.5 this is 3.</param>
            /// <param name="minorVersion">Minor version of .NET required, for .NET 3.5 this is 5.</param>
            /// <param name="minimumSPVersion">Minimum SP version required. 0 (Zero) or less means no SP requirement.</param>
            /// <returns>true if the framework is available. False if it is not available or that could not be determined.</returns>
            internal static bool IsFrameworkInstalled(int majorVersion, int minorVersion, int minimumSPVersion)
            {
                string installKeyName, installValueName, spKeyName, spValueName;

                if (!FrameworkRegistryInstallation.GetRegistryNames(majorVersion, minorVersion, out installKeyName, out installValueName, out spKeyName, out spValueName))
                {
                    return(false);
                }

                RegistryKey installKey = FrameworkRegistryInstallation.GetRegistryKeySubKey(Registry.LocalMachine, installKeyName);

                if (installKey == null)
                {
                    return(false);
                }

                int?installValue = FrameworkRegistryInstallation.GetRegistryKeyValueInt(installKey, installValueName);

                if (installValue == null)
                {
                    return(false);
                }
                // The detection logic for .NET 4.5 is to check for the existence of a DWORD key named Release under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full folder in the registry.
                // For .NET 4.5, the value of this key is the release number and not 1 (Install = 1 for .NET 3.5, .NET 4.0) . So, we need to bypasss the check below
                if ((majorVersion != 4 && minorVersion != 5) && (installValue != 1))
                {
                    Debug.Assert(PSVersionInfo.CLRVersion.Major == 4, "This check is valid only for CLR Version 4.0 and .NET Version 4.5");
                    return(false);
                }

                if (minimumSPVersion > 0)
                {
                    RegistryKey spKey = FrameworkRegistryInstallation.GetRegistryKeySubKey(Registry.LocalMachine, spKeyName);
                    if (spKey == null)
                    {
                        return(false);
                    }
                    int?spValue = FrameworkRegistryInstallation.GetRegistryKeyValueInt(spKey, spValueName);
                    if (spValue == null)
                    {
                        return(false);
                    }
                    if (spValue < minimumSPVersion)
                    {
                        return(false);
                    }
                }

                return(true);
            }
Exemplo n.º 3
0
            /// <summary>
            /// Check if the given version if the framework is installed
            /// </summary>
            /// <param name="version">version to check.
            /// for .NET Framework 3.5 and any service pack this can be new Version(3,5) or new Version(3, 5, 21022, 8).
            /// for .NET 3.5 with SP1 this should be new Version(3, 5, 30729, 1).
            /// For other versions please check the table at http://support.microsoft.com/kb/318785.
            /// </param>
            /// <returns></returns>
            internal static bool IsFrameworkInstalled(Version version)
            {
                int minorVersion, majorVersion, minimumSPVersion;

                if (!FrameworkRegistryInstallation.CanCheckFrameworkInstallation(
                        version,
                        out majorVersion,
                        out minorVersion,
                        out minimumSPVersion))
                {
                    return(false);
                }
                return(IsFrameworkInstalled(majorVersion, minorVersion, minimumSPVersion));
            }