static void ShowErrorBox(Exception exception, string message, bool mustTerminate) { try { using (ExceptionBox box = new ExceptionBox(exception, message, mustTerminate)) { if (ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.InvokeRequired) box.ShowDialog(); else box.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm); } } catch (Exception ex) { LoggingService.Warn("Error showing ExceptionBox", ex); MessageBox.Show(exception.ToString(), message, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); } }
static void ShowErrorBox(Exception exception, string message, bool mustTerminate) { try { using (ExceptionBox box = new ExceptionBox(exception, message, mustTerminate)) { try { box.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm); } catch (InvalidOperationException) { box.ShowDialog(); } } } catch (Exception ex) { LoggingService.Warn("Error showing ExceptionBox", ex); MessageBox.Show(exception.ToString(), message, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); } }
public ContextMenuStrip GetContextMenu() { ContextMenuStrip menu = new ContextMenuStrip(); ToolStripMenuItem showError; showError = new ToolStripMenuItem(); showError.Text = StringParser.Parse("${res:MainWindow.Windows.Debug.LocalVariables.ShowFullError}"); showError.Checked = false; showError.Click += delegate { using (ExceptionBox box = new ExceptionBox(error, null, false)) { box.ShowDialog(WorkbenchSingleton.MainForm); } }; menu.Items.AddRange(new ToolStripItem[] { showError }); return menu; }
static void ShowErrorBox(Exception exception, string message, bool mustTerminate) { if (exception == null) { throw new ArgumentNullException("exception"); } // ignore reentrant calls (e.g. when there's an exception in OnRender) if (showingBox) { return; } showingBox = true; try { try { AnalyticsMonitorService.TrackException(exception); } catch (Exception ex) { LoggingService.Warn("Error tracking exception", ex); } using (ExceptionBox box = new ExceptionBox(exception, message, mustTerminate)) { if (ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.InvokeRequired) { box.ShowDialog(); } else { box.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainWin32Window); } } } catch (Exception ex) { LoggingService.Warn("Error showing ExceptionBox", ex); MessageBox.Show(exception.ToString(), message, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); } finally { showingBox = false; } }
public void InitSharpDevelopCore(SharpDevelopHost.CallbackHelper callback, StartupSettings properties) { LoggingService.Info("InitSharpDevelop..."); this.callback = callback; CoreStartup startup = new CoreStartup(properties.ApplicationName); if (properties.UseSharpDevelopErrorHandler) { this.useSharpDevelopErrorHandler = true; ExceptionBox.RegisterExceptionBoxForUnhandledExceptions(); } startup.ConfigDirectory = properties.ConfigDirectory; startup.DataDirectory = properties.DataDirectory; if (properties.PropertiesName != null) { startup.PropertiesName = properties.PropertiesName; } // disable RTL: translations for the RTL languages are inactive RightToLeftConverter.RightToLeftLanguages = new string[0]; if (properties.ApplicationRootPath != null) { FileUtility.ApplicationRootPath = properties.ApplicationRootPath; } startup.StartCoreServices(); Assembly exe = Assembly.Load(properties.ResourceAssemblyName); ResourceService.RegisterNeutralStrings(new ResourceManager("Resources.StringResources", exe)); ResourceService.RegisterNeutralImages(new ResourceManager("Resources.BitmapResources", exe)); MenuCommand.LinkCommandCreator = delegate(string link) { return(new LinkCommand(link)); }; StringParser.RegisterStringTagProvider(new SharpDevelopStringTagProvider()); LoggingService.Info("Looking for AddIns..."); foreach (string file in properties.addInFiles) { startup.AddAddInFile(file); } foreach (string dir in properties.addInDirectories) { startup.AddAddInsFromDirectory(dir); } if (properties.AllowAddInConfigurationAndExternalAddIns) { startup.ConfigureExternalAddIns(Path.Combine(PropertyService.ConfigDirectory, "AddIns.xml")); } if (properties.AllowUserAddIns) { startup.ConfigureUserAddIns(Path.Combine(PropertyService.ConfigDirectory, "AddInInstallTemp"), Path.Combine(PropertyService.ConfigDirectory, "AddIns")); } LoggingService.Info("Loading AddInTree..."); startup.RunInitialization(); // Register events to marshal back Project.ProjectService.StartBuild += delegate { this.callback.StartBuild(); }; Project.ProjectService.EndBuild += delegate { this.callback.EndBuild(); }; Project.ProjectService.SolutionLoaded += delegate { this.callback.SolutionLoaded(); }; Project.ProjectService.SolutionClosed += delegate { this.callback.SolutionClosed(); }; Project.ProjectService.SolutionConfigurationChanged += delegate { this.callback.SolutionConfigurationChanged(); }; FileUtility.FileLoaded += delegate(object sender, FileNameEventArgs e) { this.callback.FileLoaded(e.FileName); }; FileUtility.FileSaved += delegate(object sender, FileNameEventArgs e) { this.callback.FileSaved(e.FileName); }; LoggingService.Info("InitSharpDevelop finished"); }
public void InitSharpDevelopCore(SharpDevelopHost.CallbackHelper callback, StartupSettings properties) { // Initialize the most important services: var container = new SharpDevelopServiceContainer(); container.AddFallbackProvider(ServiceSingleton.FallbackServiceProvider); container.AddService(typeof(IMessageService), new SDMessageService()); container.AddService(typeof(ILoggingService), new log4netLoggingService()); ServiceSingleton.ServiceProvider = container; LoggingService.Info("InitSharpDevelop..."); this.callback = callback; CoreStartup startup = new CoreStartup(properties.ApplicationName); if (properties.UseSharpDevelopErrorHandler) { this.useSharpDevelopErrorHandler = true; ExceptionBox.RegisterExceptionBoxForUnhandledExceptions(); } string configDirectory = properties.ConfigDirectory; string dataDirectory = properties.DataDirectory; string propertiesName; if (properties.PropertiesName != null) { propertiesName = properties.PropertiesName; } else { propertiesName = properties.ApplicationName + "Properties"; } if (properties.ApplicationRootPath != null) { FileUtility.ApplicationRootPath = properties.ApplicationRootPath; } if (configDirectory == null) { configDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), properties.ApplicationName); } var propertyService = new PropertyService( DirectoryName.Create(configDirectory), DirectoryName.Create(dataDirectory ?? Path.Combine(FileUtility.ApplicationRootPath, "data")), propertiesName); startup.StartCoreServices(propertyService); Assembly exe = Assembly.Load(properties.ResourceAssemblyName); SD.ResourceService.RegisterNeutralStrings(new ResourceManager("ICSharpCode.SharpDevelop.Resources.StringResources", exe)); SD.ResourceService.RegisterNeutralImages(new ResourceManager("ICSharpCode.SharpDevelop.Resources.BitmapResources", exe)); CommandWrapper.LinkCommandCreator = (link => new LinkCommand(link)); CommandWrapper.WellKnownCommandCreator = Core.Presentation.MenuService.GetKnownCommand; CommandWrapper.RegisterConditionRequerySuggestedHandler = (eh => CommandManager.RequerySuggested += eh); CommandWrapper.UnregisterConditionRequerySuggestedHandler = (eh => CommandManager.RequerySuggested -= eh); StringParser.RegisterStringTagProvider(new SharpDevelopStringTagProvider()); LoggingService.Info("Looking for AddIns..."); foreach (string file in properties.addInFiles) { startup.AddAddInFile(file); } foreach (string dir in properties.addInDirectories) { startup.AddAddInsFromDirectory(dir); } if (properties.AllowAddInConfigurationAndExternalAddIns) { startup.ConfigureExternalAddIns(Path.Combine(configDirectory, "AddIns.xml")); } if (properties.AllowUserAddIns) { startup.ConfigureUserAddIns(Path.Combine(configDirectory, "AddInInstallTemp"), Path.Combine(configDirectory, "AddIns")); } LoggingService.Info("Loading AddInTree..."); startup.RunInitialization(); ((AssemblyParserService)SD.AssemblyParserService).DomPersistencePath = properties.DomPersistencePath; // Register events to marshal back Project.ProjectService.BuildStarted += delegate { this.callback.StartBuild(); }; Project.ProjectService.BuildFinished += delegate { this.callback.EndBuild(); }; Project.ProjectService.SolutionLoaded += delegate { this.callback.SolutionLoaded(); }; Project.ProjectService.SolutionClosed += delegate { this.callback.SolutionClosed(); }; FileUtility.FileLoaded += delegate(object sender, FileNameEventArgs e) { this.callback.FileLoaded(e.FileName); }; FileUtility.FileSaved += delegate(object sender, FileNameEventArgs e) { this.callback.FileSaved(e.FileName); }; LoggingService.Info("InitSharpDevelop finished"); }
static void ShowErrorBox(Exception exception, string message, bool mustTerminate) { if (exception == null) throw new ArgumentNullException("exception"); // ignore reentrant calls (e.g. when there's an exception in OnRender) if (showingBox) return; showingBox = true; try { try { AnalyticsMonitorService.TrackException(exception); } catch (Exception ex) { LoggingService.Warn("Error tracking exception", ex); } using (ExceptionBox box = new ExceptionBox(exception, message, mustTerminate)) { if (ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.InvokeRequired) box.ShowDialog(); else box.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainWin32Window); } } catch (Exception ex) { LoggingService.Warn("Error showing ExceptionBox", ex); MessageBox.Show(exception.ToString(), message, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); } finally { showingBox = false; } }