static void Main() { try { //// Uncomment to see Console. Must be called before anything writes to Console. //// Only use while debugging. Acts erratically in the wild //AllocConsole(); ApplicationConfiguration.Initialize(); //***********************************************// // // // do not use Configuration before this line // // // //***********************************************// // Migrations which must occur before configuration is loaded for the first time. Usually ones which alter the Configuration var config = AppScaffolding.LibationScaffolding.RunPreConfigMigrations(); // do this as soon as possible (post-config) RunInstaller(config); // most migrations go in here AppScaffolding.LibationScaffolding.RunPostConfigMigrations(config); // migrations which require Forms or are long-running RunWindowsOnlyMigrations(config); MessageBoxVerboseLoggingWarning.ShowIfTrue(); #if !DEBUG checkForUpdate(); #endif AppScaffolding.LibationScaffolding.RunPostMigrationScaffolding(config); } catch (Exception ex) { var title = "Fatal error, pre-logging"; var body = "An unrecoverable error occurred. Since this error happened before logging could be initialized, this error can not be written to the log file."; try { MessageBoxAlertAdmin.Show(body, title, ex); } catch { MessageBox.Show($"{body}\r\n\r\n{ex.Message}\r\n\r\n{ex.StackTrace}", title, MessageBoxButtons.OK, MessageBoxIcon.Error); } return; } Application.Run(new Form1()); }
private void exportLibraryToolStripMenuItem_Click(object sender, EventArgs e) { try { var saveFileDialog = new SaveFileDialog { Title = "Where to export Library", Filter = "Excel Workbook (*.xlsx)|*.xlsx|CSV files (*.csv)|*.csv|JSON files (*.json)|*.json" // + "|All files (*.*)|*.*" }; if (saveFileDialog.ShowDialog() != DialogResult.OK) { return; } // FilterIndex is 1-based, NOT 0-based switch (saveFileDialog.FilterIndex) { case 1: // xlsx default: LibraryExporter.ToXlsx(saveFileDialog.FileName); break; case 2: // csv LibraryExporter.ToCsv(saveFileDialog.FileName); break; case 3: // json LibraryExporter.ToJson(saveFileDialog.FileName); break; } MessageBox.Show("Library exported to:\r\n" + saveFileDialog.FileName); } catch (Exception ex) { MessageBoxAlertAdmin.Show("Error attempting to export your library.", "Error exporting", ex); } }