public static void WriteMP3Tags(CD cd, int trackId = 0) { for (int i = 0; i < cd.Tracks.Count; i++) { try { if ((trackId == 0 || cd.Tracks[i].ID == trackId) && !string.IsNullOrEmpty(cd.Tracks[i].Soundfile) && File.Exists(cd.Tracks[i].Soundfile)) { WriteMP3Tags(cd.Tracks[i].Soundfile, cd, i); } } catch (Exception e) { System.Windows.Application.Current.Dispatcher.Invoke( new Action(delegate { // Sicherheitshalber mal abgefragt UnhandledExceptionWindow unhandledExceptionWindow = new UnhandledExceptionWindow(e); unhandledExceptionWindow.ShowDialog(); })); } } }
private void Button_Click(object sender, RoutedEventArgs e) { var t1 = TaskManager.StartNew(() => { throw new NotImplementedException("Mensaje de la excepción que puede ser muy largo, pero muy muy muy largo, vamos no te fies que a lo mejor no te cabe en la ventana ni de coña macho,\r\nLOL\r\nLOL\r\nLOL\r\nLOL\r\nLOL\r\nLOL\r\nLOL\r\nLOL\r\nLOL\r\nLOL tendrás que apañartelas como sea para que quede bonito y accesible :)" , new KeyNotFoundException("Mensaje de la excepción que puede ser muy largo, pero muy muy muy largo, vamos no te fies que a lo mejor no te cabe en la ventana ni de coña macho, tendrás que apañartelas como sea para que quede bonito y accesible :)") ); }); var t2 = TaskManager.StartNew(() => { throw new ApplicationException("Peto la aplicación :)"); }); try { Task.WaitAll(t1, t2); } catch (AggregateException ex) { UnhandledExceptionWindow win = null; win = new UnhandledExceptionWindow(ex, true, () => { MessageBox.Show("Report sent with content:\r\n"); return(Task.CompletedTask); }) { Message = "Se ha producido un error grave", Buttons = UnhandledExceptionWindowButtons.CloseWindow, CanShowDetails = true, //SendReportCommand = new GenericCommand<string>(content => MessageBox.Show("Report sent with content:\r\n" + content)) }; win.ShowDialog(); } }
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { var w = new UnhandledExceptionWindow(e.ExceptionObject as Exception); w.ShowDialog(); Shutdown(); Environment.Exit(1); }
void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { UnhandledExceptionWindow unhandledExceptionWindow = new UnhandledExceptionWindow(e.Exception); unhandledExceptionWindow.ShowDialog(); // Prevent default unhandled exception processing e.Handled = true; }
private void DispatchUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { e.Handled = !IsCriticalException(e.Exception); UnhandledExceptionWindow dialog = new UnhandledExceptionWindow(e.Exception); dialog.Owner = MainWindow; dialog.ShowDialog(); }
private static void LogUnhandledException(Exception exception, string source) { string message; string details; try { var assemblyName = Assembly.GetExecutingAssembly().GetName(); message = "Er is een onverwachte fout opgetreden." + Environment.NewLine; message += "Gelieve dit probleem inclusief onderstaande details doorgeven aan de ontwikkelaar."; details = $"Fout in TLCGen (versie {Assembly.GetCallingAssembly().GetName().Version})." + Environment.NewLine + Environment.NewLine; details += $"Bron: {source}, in {assemblyName.Name} v{assemblyName.Version}." + Environment.NewLine + Environment.NewLine; details += exception; } catch (Exception ex) { message = "Er is een onverwachte fout opgetreden in LogUnhandledException." + Environment.NewLine; message += "Gelieve dit probleem inclusief onderstaande details doorgeven aan de ontwikkelaar."; details = "Fout in LogUnhandledException." + Environment.NewLine + Environment.NewLine; details += ex + Environment.NewLine + Environment.NewLine; details += "Oorspronkelijke fout:" + Environment.NewLine + Environment.NewLine + exception; } if (GalaSoft.MvvmLight.Threading.DispatcherHelper.UIDispatcher != null) { GalaSoft.MvvmLight.Threading.DispatcherHelper.UIDispatcher.Invoke(() => { var win = new UnhandledExceptionWindow { DialogTitle = "Onverwachte fout in TLCGen", DialogMessage = message, DialogExpceptionText = details }; win.ShowDialog(); }); } else { try { var win = new UnhandledExceptionWindow { DialogTitle = "Onverwachte fout in TLCGen", DialogMessage = message, DialogExpceptionText = details }; win.ShowDialog(); } catch { MessageBox.Show("Onverwachte fout in TLCGen", message + Environment.NewLine + details); } } }
private static void CurrentDomainOnUnhandledException(object sender, UnhandledExceptionEventArgs e) { if (!FrmSplashScreen.getInstance().IsDisposed) { FrmSplashScreen.getInstance().Close(); } var window = new UnhandledExceptionWindow(e.ExceptionObject as Exception, e.IsTerminating); window.ShowDialog(FrmMain.Default); }
private static void ApplicationOnThreadException(object sender, ThreadExceptionEventArgs e) { if (!FrmSplashScreen.getInstance().IsDisposed) { FrmSplashScreen.getInstance().Close(); } var window = new UnhandledExceptionWindow(e.Exception, false); window.ShowDialog(FrmMain.Default); }
private void PerformMultiEdit(MyMusicListItem musicItem, Field field, int columnIndex) { WaitProgressUserControl waitProgressUserControl = new WaitProgressUserControl(); GlobalServices.ModalService.NavigateTo(waitProgressUserControl, StringTable.MultiTagEdit, delegate(bool returnValue) { }, false); waitProgressUserControl.progressBar.Maximum = dataGrid.SelectedItems.Count; List <MyMusicListItem> selectedItems = new List <MyMusicListItem>(); foreach (MyMusicListItem item in dataGrid.SelectedItems) { selectedItems.Add(item); } BackgroundWorker bw = new BackgroundWorker(); bw.DoWork += delegate { for (int i = 0; i < selectedItems.Count; i++) { MyMusicListItem item = selectedItems[i]; item.Items[columnIndex] = musicItem.Items[columnIndex]; EditTrackField(columnIndex, field, item); if (waitProgressUserControl.Canceled) { break; } this.Dispatcher.Invoke((Action)(() => { waitProgressUserControl.progressBar.Value++; })); } }; bw.RunWorkerCompleted += delegate(object completedSender, RunWorkerCompletedEventArgs completedEventArgs) { if (completedEventArgs.Error != null) { UnhandledExceptionWindow unhandledExceptionWindow = new UnhandledExceptionWindow(completedEventArgs.Error); unhandledExceptionWindow.ShowDialog(); } GlobalServices.ModalService.CloseModal(); UpdateList(); }; bw.RunWorkerAsync(); }
private static void ShowExceptionDialog(Exception ex) { try { var progInfo = new ProgramInformation("Wsapm.exe", VersionInformation.Version.ToString(3)); var exceptionDialog = new UnhandledExceptionWindow(ex, progInfo, Wsapm.Resources.Wsapm.General_MessageBoxErrorTitle, new BitmapImage(new Uri("pack://application:,,,/Resources/app.ico"))); exceptionDialog.ShowDialog(); } catch (Exception) { // If something fails when showing dialog, the application has to be shut down. // Use specific return coded to signal severe error. Application.Current.Shutdown(ReturnCodeSevereError); } }
void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { Exception exception = e.ExceptionObject as Exception; if (exception != null) { UnhandledExceptionWindow unhandledExceptionWindow = new UnhandledExceptionWindow(exception); unhandledExceptionWindow.ShowDialog(); } else { MessageBox.Show("Unhandled exception occured."); } }
public MainWindowViewModel() { var tmpCurDir = Directory.GetCurrentDirectory(); Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); try { GuiActionsManager.SetStatusBarMessage = (string text) => { StatusBarVM.StatusText = text; }; MessengerInstance.Register(this, new Action <Messaging.Requests.PrepareForGenerationRequest>(OnPrepareForGenerationRequest)); MessengerInstance.Register(this, new Action <ControllerCodeGeneratedMessage>(OnControllerCodeGenerated)); MessengerInstance.Register(this, new Action <ControllerProjectGeneratedMessage>(OnControllerProjectGenerated)); MessengerInstance.Register(this, new Action <ControllerFileNameChangedMessage>(OnControllerFileNameChanged)); // Load application settings and defaults TLCGenSplashScreenHelper.ShowText("Laden instellingen en defaults..."); SettingsProvider.Default.LoadApplicationSettings(); DefaultsProvider.Default.LoadSettings(); TemplatesProvider.Default.LoadSettings(); TLCGenModelManager.Default.InjectDefaultAction((x, s) => DefaultsProvider.Default.SetDefaultsOnModel(x, s)); TLCGenControllerDataProvider.Default.InjectDefaultAction(x => DefaultsProvider.Default.SetDefaultsOnModel(x)); // Load available applicationparts and plugins var assms = Assembly.GetExecutingAssembly(); var types = from t in assms.GetTypes() where t.IsClass && t.Namespace == "TLCGen.ViewModels" select t; TLCGenSplashScreenHelper.ShowText("Laden applicatie onderdelen..."); TLCGenPluginManager.Default.LoadApplicationParts(types.ToList()); TLCGenSplashScreenHelper.ShowText("Laden plugins..."); TLCGenPluginManager.Default.LoadPlugins(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins\\")); // Instantiate all parts _ApplicationParts = new List <Tuple <TLCGenPluginElems, ITLCGenPlugin> >(); var parts = TLCGenPluginManager.Default.ApplicationParts.Concat(TLCGenPluginManager.Default.ApplicationPlugins); foreach (var part in parts) { ITLCGenPlugin instpl = part.Item2; TLCGenSplashScreenHelper.ShowText($"Laden plugin {instpl.GetPluginName()}..."); var flags = Enum.GetValues(typeof(TLCGenPluginElems)); foreach (TLCGenPluginElems elem in flags) { if ((part.Item1 & elem) == elem) { switch (elem) { case TLCGenPluginElems.Generator: Generators.Add(new IGeneratorViewModel(instpl as ITLCGenGenerator)); break; case TLCGenPluginElems.HasSettings: ((ITLCGenHasSettings)instpl).LoadSettings(); break; case TLCGenPluginElems.Importer: MenuItem mi = new MenuItem(); mi.Header = instpl.GetPluginName(); mi.Command = ImportControllerCommand; mi.CommandParameter = instpl; ImportMenuItems.Add(mi); break; case TLCGenPluginElems.IOElementProvider: break; case TLCGenPluginElems.MenuControl: PluginMenuItems.Add(((ITLCGenMenuItem)instpl).Menu); break; case TLCGenPluginElems.TabControl: break; case TLCGenPluginElems.ToolBarControl: break; case TLCGenPluginElems.XMLNodeWriter: break; case TLCGenPluginElems.PlugMessaging: (instpl as ITLCGenPlugMessaging).UpdateTLCGenMessaging(); break; case TLCGenPluginElems.Switcher: (instpl as ITLCGenSwitcher).ControllerSet += (sender, model) => { SetController(model); }; (instpl as ITLCGenSwitcher).FileNameSet += (sender, model) => { TLCGenControllerDataProvider.Default.ControllerFileName = model; }; break; } } TLCGenPluginManager.LoadAddinSettings(instpl, part.Item2.GetType(), SettingsProvider.Default.Settings.CustomData); } _ApplicationParts.Add(new Tuple <TLCGenPluginElems, ITLCGenPlugin>(part.Item1, instpl as ITLCGenPlugin)); } if (Generators.Count > 0) { SelectedGenerator = Generators[0]; } // Construct the ViewModel ControllerVM = new ControllerViewModel(); if (!DesignMode.IsInDesignMode) { if (Application.Current != null && Application.Current.MainWindow != null) { Application.Current.MainWindow.Closing += new CancelEventHandler(MainWindow_Closing); } } #if !DEBUG Application.Current.DispatcherUnhandledException += (o, e) => { string message = "Er is een onverwachte fout opgetreden.\n\n"; if (TLCGenControllerDataProvider.Default.Controller != null) { try { string t = TLCGenControllerDataProvider.Default.ControllerFileName; if (string.IsNullOrWhiteSpace(TLCGenControllerDataProvider.Default.ControllerFileName)) { TLCGenControllerDataProvider.Default.ControllerFileName = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "TLC_recoverysave.tlc"); } TLCGenControllerDataProvider.Default.ControllerFileName = System.IO.Path.Combine( System.IO.Path.GetDirectoryName(TLCGenControllerDataProvider.Default.ControllerFileName), DateTime.Now.ToString("yyyyMMdd-HHmmss-", System.Globalization.CultureInfo.InvariantCulture) + System.IO.Path.GetFileName(TLCGenControllerDataProvider.Default.ControllerFileName)); TLCGenControllerDataProvider.Default.SaveController(); message += "De huidige regeling is hier opgeslagen:\n" + TLCGenControllerDataProvider.Default.ControllerFileName + "\n\n"; if (t != null) { TLCGenControllerDataProvider.Default.ControllerFileName = t; } } catch { } } message += "Gelieve dit probleem inclusief onderstaande details doorgeven aan de ontwikkelaar:\n\n"; var win = new TLCGen.Dialogs.UnhandledExceptionWindow(); win.DialogTitle = "Onverwachte fout in TLCGen"; win.DialogMessage = message; win.DialogExpceptionText = e.Exception.ToString(); win.ShowDialog(); }; #endif } catch (Exception e) { TLCGenSplashScreenHelper.Hide(); string message = "Er is een onverwachte fout opgetreden.\n\n"; message += "Gelieve dit probleem inclusief onderstaande details doorgeven aan de ontwikkelaar:\n\n"; var win = new UnhandledExceptionWindow { DialogTitle = "Onverwachte fout in TLCGen", DialogMessage = message, DialogExpceptionText = e.ToString() }; win.ShowDialog(); } Directory.SetCurrentDirectory(tmpCurDir); #if !DEBUG // Find out if there is a newer version available via Wordpress REST API Task.Run(() => { // clean potential old data var key = Registry.CurrentUser.OpenSubKey("Software", true); var sk1 = key?.OpenSubKey("CodingConnected e.U.", true); var sk2 = sk1?.OpenSubKey("TLCGen", true); var tempFile = (string)sk2?.GetValue("TempInstallFile", null); if (tempFile != null) { if (File.Exists(tempFile)) { File.Delete(tempFile); } sk2?.DeleteValue("TempInstallFile"); } var webRequest = WebRequest.Create(@"https://codingconnected.eu/wp-json/wp/v2/pages/1105"); webRequest.UseDefaultCredentials = true; using (var response = webRequest.GetResponse()) using (var content = response.GetResponseStream()) if (content != null) { using (var reader = new StreamReader(content)) { var strContent = reader.ReadToEnd().Replace("\n", ""); var jsonDeserializer = new JavaScriptSerializer(); var deserializedJson = jsonDeserializer.Deserialize <dynamic>(strContent); if (deserializedJson == null) { return; } var contentData = deserializedJson["content"]; if (contentData == null) { return; } var renderedData = contentData["rendered"]; if (renderedData == null) { return; } var data = renderedData as string; if (data == null) { return; } var all = data.Split('\r'); var tlcgenVer = all.FirstOrDefault(v => v.StartsWith("TLCGen=")); if (tlcgenVer == null) { return; } var oldvers = Assembly.GetEntryAssembly().GetName().Version.ToString().Split('.'); var newvers = tlcgenVer.Replace("TLCGen=", "").Split('.'); bool newer = false; if (oldvers.Length > 0 && oldvers.Length == newvers.Length) { for (int i = 0; i < newvers.Length; i++) { var o = int.Parse(oldvers[i]); var n = int.Parse(newvers[i]); if (o > n) { break; } if (n > o) { newer = true; break; } } } if (newer) { DispatcherHelper.CheckBeginInvokeOnUI(() => { var w = new NewVersionAvailableWindow(tlcgenVer.Replace("TLCGen=", "")); w.ShowDialog(); }); } } } }); #endif }
/// <summary> /// Handles an exception through the Unhandled Exception window. /// </summary> /// <param name="ex">Exception to display</param> private static void HandleUnhandledException(Exception ex) { if (Debugger.IsAttached) return; if (s_errorWindowIsShown) return; s_errorWindowIsShown = true; try { // Some exceptions may be thrown on a worker thread so we need to invoke them to the UI thread, // if we are already on the UI thread nothing changes if (s_mainWindow!= null && s_mainWindow.InvokeRequired) { Dispatcher.Invoke(() => HandleUnhandledException(ex)); return; } using (UnhandledExceptionWindow form = new UnhandledExceptionWindow(ex)) { if (s_mainWindow != null && !s_mainWindow.IsDisposed) form.ShowDialog(s_mainWindow); else form.ShowDialog(); } // Notify Gooogle Analytics about ending via the Unhandled Exception window GAnalyticsTracker.TrackEnd(typeof(Program)); } catch (Exception e) { StringBuilder messageBuilder = new StringBuilder(); messageBuilder .AppendLine(@"An error occurred and EVEMon was unable to handle the error message gracefully.") .AppendLine() .AppendLine($"The exception encountered was '{e.Message}'."); if (ex.GetBaseException().Message != e.Message) { messageBuilder .AppendLine() .AppendLine($"The original exception encountered was '{ex.GetBaseException().Message}'."); } messageBuilder .AppendLine() .AppendLine(@"Please report this on the EVEMon forums."); if (EveMonClient.IsDebugBuild) messageBuilder.AppendLine().AppendLine(UnhandledExceptionWindow.GetRecursiveStackTrace(ex)); MessageBox.Show(messageBuilder.ToString(), @"EVEMon Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } Environment.Exit(1); }