private static string SafelyGetAppInstalledPath() { try { return(MsiUtilities.GetAppInstalledPath()); } catch (InvalidOperationException e) { ExceptionReporter.ReportException(e); return(null); } }
public StartUpModeControl() { this.VersionString = VersionTools.GetAppVersion(); InitializeComponent(); // If possible, point to build-specific release notes Uri releaseNotesUri = MsiUtilities.GetReleaseNotesUri(new SetupExceptionReporter()); if (releaseNotesUri != null) { hlLink.NavigateUri = releaseNotesUri; } }
/// <summary> /// Infer UIAccess state from the existing manifest files. Assume false unless proven otherwise /// </summary> private static bool IsUIAccessEnabled() { try { string appPath = Path.GetDirectoryName(MsiUtilities.GetAppInstalledPath()); string appManifestContents = File.ReadAllText(Path.Combine(appPath, AppManifestFile)); string enabledManifestContents = File.ReadAllText(Path.Combine(appPath, EnabledManifestFile)); return(appManifestContents == enabledManifestContents); } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception e) { // Report the error, assume no UIAccess EventLogger.WriteWarningMessage("Unable to determine UIAccess status. Assuming disabled. Detail: {0}", e.ToString()); return(false); } #pragma warning restore CA1031 // Do not catch general exception types }
/// <summary> /// Update manifest files as needed for UIAccess support /// </summary> /// <param name="enableUIAccess">Desired state of UIAccess.</param> private static void SetManifestForUIAccess(bool enableUIAccess) { if (!enableUIAccess) { return; // UIAccess is disabled by default } try { string appPath = Path.GetDirectoryName(MsiUtilities.GetAppInstalledPath()); string enabledManifestContents = File.ReadAllText(Path.Combine(appPath, EnabledManifestFile)); File.WriteAllText(Path.Combine(appPath, AppManifestFile), enabledManifestContents, System.Text.Encoding.UTF8); EventLogger.WriteInformationalMessage("UIAccess has been enabled"); } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception e) { // Report the error, assume no UIAccess EventLogger.WriteWarningMessage("Unable to enable UIAccess. Detail: {0}", e.ToString()); } #pragma warning restore CA1031 // Do not catch general exception types }
/// <summary> /// Production ctor - MUST be a default ctor or extensions will break /// </summary> public AutoUpdate() : this(ConfiguredReleaseChannelProvider, () => MsiUtilities.GetInstalledProductVersion(ExceptionReporter), new ProductionChannelInfoProvider(new GitHubWrapper(ExceptionReporter), ExceptionReporter)) { }