/// <summary> /// Launches a window requested by another instance of OpenLiveWriter.exe. /// </summary> private static bool LaunchAdditionalInstance(string[] args) { // This process received a request from another process before // initialization was complete; this request should be considered // a failure, and the other process should try again if (!initComplete) { return(false); } // Do this only after initComplete is true, otherwise currentUICulture could be null. CultureHelper.ApplyUICulture(currentUICulture.Name); try { // TODO:OLW // using (Setup Setup = new Setup()) { try { // TODO:OLW // Set native code's preferred language list // Setup.SetThreadUILanguages(); ApplicationLauncher.LaunchBloggingForm(args, null, false); return(true); } catch (ManualKeepaliveOperationException) { return(false); } catch (Exception e) { Trace.Fail(e.ToString()); return(true); } finally { // TODO:OLW // Setup.ClearThreadUILanguages(); } } } catch (Exception) { // Most likely we failed to create WLSetupClass, installation corrupt or incomplete // Redirect user to repair/reinstall. DisplayMessage.Show(MessageId.WriterCannotStart); } return(true); }
/// <summary> /// Launches a window as part of the starting of a process. /// </summary> private static void LaunchFirstInstance(IDisposable splashScreen, string[] args) { try { PostEditorFile.Initialize(); MaybeMigrateSettings(); // Make sure editor options are available before we launch the first instance. GlobalEditorOptions.Init(new OpenLiveWriterContentTarget(), new OpenLiveWriterSettingsProvider()); // register file associations // Removing this call, as it causes exceptions in Vista // RegisterFileAssociations() ; Trace.WriteLine(String.Format(CultureInfo.InvariantCulture, "Starting {0} {1}", ApplicationEnvironment.ProductNameQualified, ApplicationEnvironment.ProductVersion)); Trace.WriteLine(String.Format(CultureInfo.InvariantCulture, ".NET version: {0}", Environment.Version)); // force initialization which may fail with error dialogs // and/or cause the whole application to not load if (PostEditorLifetimeManager.Initialize()) { initComplete = true; // launch blogging form ApplicationLauncher.LaunchBloggingForm(args, splashScreen, true); } ManualKeepalive.Wait(true); } catch (DirectoryException ex) { if (ex.MessageId != null) { DisplayMessage.Show(ex.MessageId.Value); } else if (ex.Path != null) { DisplayMessage.Show(MessageId.DirectoryFail, ex.Path); } else { UnexpectedErrorMessage.Show(ex); } } catch (Exception ex) { UnexpectedErrorMessage.Show(ex); } finally { try { // shut down PostEditorLifetimeManager.Uninitialize(); TempFileManager.Instance.Dispose(); // Delete legacy post supporting files that might have // been orphaned by a previous version of Writer. We // now keep these in the temp directory like everything // else string legacyPostSupportingFiles = Path.Combine(ApplicationEnvironment.ApplicationDataDirectory, "PostSupportingFiles"); if (Directory.Exists(legacyPostSupportingFiles)) { Directory.Delete(legacyPostSupportingFiles, true); } } catch (Exception ex2) { Trace.Fail(ex2.ToString()); } } }