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 (FrameWork.Gui.WorkbenchSingleton.InvokeRequired) { box.ShowDialog(); } else { box.ShowDialog(FrameWork.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(StartUpHost.CallbackHelper callback, StartupSettings properties) { // creating the service manager initializes the logging service etc. ICSharpCode.Core.Services.ServiceManager.Instance = new FWServiceManager(); LoggingService.Info("InitFrameWork..."); 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; } //AssemblyParserService.DomPersistencePath = properties.DomPersistencePath;//by hanz if (properties.ApplicationRootPath != null) { FileUtility.ApplicationRootPath = properties.ApplicationRootPath; } startup.StartCoreServices(); Assembly exe = Assembly.Load(properties.ResourceAssemblyName); ResourceService.RegisterNeutralStrings(new ResourceManager("StartUp.Resources.StringResources", exe)); ResourceService.RegisterNeutralImages(new ResourceManager("StartUp.Resources.BitmapResources", exe)); MenuCommand.LinkCommandCreator = delegate(string link) { return(new LinkCommand(link)); }; MenuCommand.KnownCommandCreator = CreateICommandForWPFCommand; ICSharpCode.Core.Presentation.MenuService.LinkCommandCreator = MenuCommand.LinkCommandCreator; //StringParser.RegisterStringTagProvider(new SharpDevelopStringTagProvider());//by hanz 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(); LoggingService.Info("InitFrameWork finished"); }