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); }
public static IDisposable SetHostingRuntimePolicyValues( bool doNotLaunchV3AppInV4Runtime, HostingRuntimePolicyRestoreMode restoreMode) { var restoreHelper = new HostingRuntimePolicyRestoreHelper(SupportedRegistryViews, restoreMode); SupportedRegistryViews.ForEach((rv) => SetHostingRuntimePolicyValue(rv, doNotLaunchV3AppInV4Runtime)); return(restoreHelper); }
/// <summary> /// Constructor /// </summary> /// <param name="registryViews">Registry Views being recorded for later restoration</param> /// <param name="restoreMode">Determines whether values are being saved for later restoration, or /// whether <see cref="Dispose"/> will reset the values to <see cref="DefaultValue"/></param> public HostingRuntimePolicyRestoreHelper(List <RegistryView> registryViews, HostingRuntimePolicyRestoreMode restoreMode) { RestoreValues = new Dictionary <RegistryView, bool>(); foreach (var registryView in registryViews) { bool restoreValue = restoreMode == HostingRuntimePolicyRestoreMode.ResetToDefault ? DefaultValue : GetHostingRuntimePolicyValue(registryView); RestoreValues.Add(registryView, restoreValue); } }