using System; using System.IO; using System.Runtime.InteropServices; using System.Windows; using System.Windows.Threading; using tsf_3074.Data; using tsf_3074.Window; using tsf_3074.Windows.Dialog; namespace tsf_3074 { /// /// Interaction logic for App.xaml /// public partial class App { private void App_OnStartup(object sender, StartupEventArgs e) { SetCurrentProcessExplicitAppUserModelID("com.squirrel.Tsf"); Config.Instance.ToString(); Tsf.FFullGame.ToString(); var window = new OverlayWindow(); window.Show(); } private void App_OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { // export the exception info var date = DateTime.Now; var fileName = $"tsf-crash_{date.Day}_{date.Month}_{date.Year}-{date.Hour}_{date.Minute}_{date.Second}.txt"; using (var writer = new StreamWriter(fileName, true)) { writer.WriteLine("##########" + DateTime.Now + "##########"); writer.WriteLine("An exception occurred when loading tsf."); writer.WriteLine(e.Exception); } Console.WriteLine("TSF is crashed."); Console.WriteLine(fileName); Console.WriteLine(e.Exception); e.Handled = true; Shutdown(); } [DllImport("shell32.dll", SetLastError = true)] public static extern void SetCurrentProcessExplicitAppUserModelID( [MarshalAs(UnmanagedType.LPWStr)] string appUserModelId); } }