示例#1
0
        public static IDisposable SetHostingRuntimePolicyValues(
            bool?doNotLaunchV3AppInV4Runtime32Bit,
            bool?doNotLaunchV3AppInV4Runtime64Bit,
            HostingRuntimePolicyRestoreMode restoreMode)
        {
            var registryViews = new List <RegistryView>();

            if (doNotLaunchV3AppInV4Runtime32Bit.HasValue)
            {
                registryViews.Add(RegistryView.Registry32);
            }

            if (doNotLaunchV3AppInV4Runtime64Bit.HasValue && Environment.Is64BitOperatingSystem)
            {
                registryViews.Add(RegistryView.Registry64);
            }

            var restoreHelper =
                new HostingRuntimePolicyRestoreHelper(registryViews, restoreMode);

            if (doNotLaunchV3AppInV4Runtime32Bit.HasValue)
            {
                SetHostingRuntimePolicyValue(RegistryView.Registry32, doNotLaunchV3AppInV4Runtime32Bit.Value);
            }

            if (doNotLaunchV3AppInV4Runtime64Bit.HasValue && Environment.Is64BitOperatingSystem)
            {
                SetHostingRuntimePolicyValue(RegistryView.Registry64, doNotLaunchV3AppInV4Runtime64Bit.Value);
            }

            return(restoreHelper);
        }
示例#2
0
        public static IDisposable SetHostingRuntimePolicyValues(
            bool doNotLaunchV3AppInV4Runtime,
            HostingRuntimePolicyRestoreMode restoreMode)
        {
            var restoreHelper =
                new HostingRuntimePolicyRestoreHelper(SupportedRegistryViews, restoreMode);

            SupportedRegistryViews.ForEach((rv) => SetHostingRuntimePolicyValue(rv, doNotLaunchV3AppInV4Runtime));

            return(restoreHelper);
        }