-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
82 lines (76 loc) · 2.59 KB
/
Copy pathProgram.cs
File metadata and controls
82 lines (76 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using Microsoft.UI.Xaml;
using System;
using System.IO;
using System.Linq;
namespace STAGE
{
internal class Program
{
[STAThread]
static void Main(string[] args)
{
AppDomain.CurrentDomain.UnhandledException += (_, e) =>
LogCrash("AppDomain: " + (e.ExceptionObject?.ToString() ?? "unknown"));
try
{
try
{
UserAssetStore.MigrateConfiguredAssets();
}
catch (Exception ex)
{
LogCrash("User asset migration: " + ex);
}
try
{
_ = ModBackupService.CleanupExpiredAutomaticBackups(
Settings.ManagedModFolders,
Settings.AutoBackupRetentionDays);
}
catch (Exception ex)
{
LogCrash("Automatic backup retention: " + ex);
}
global::WinRT.ComWrappersSupport.InitializeComWrappers();
global::Microsoft.UI.Xaml.Application.Start((p) =>
{
try
{
var context = new global::Microsoft.UI.Dispatching.DispatcherQueueSynchronizationContext(
global::Microsoft.UI.Dispatching.DispatcherQueue.GetForCurrentThread());
global::System.Threading.SynchronizationContext.SetSynchronizationContext(context);
_ = new App();
}
catch (Exception ex)
{
LogCrash("Application.Start callback: " + ex);
global::System.Environment.Exit(1);
}
});
}
catch (Exception ex)
{
LogCrash("Main: " + ex);
global::System.Environment.Exit(1);
}
}
static void LogCrash(string message)
{
string text = $"[{DateTime.Now}]\n{message}\n";
string[] paths =
{
AppEnvironment.CrashLogPath,
Path.Combine(AppContext.BaseDirectory, "crash.log")
};
foreach (string path in paths.Distinct(StringComparer.OrdinalIgnoreCase))
{
try
{
Directory.CreateDirectory(Path.GetDirectoryName(path)!);
File.WriteAllText(path, text);
}
catch { }
}
}
}
}