Skip to content

Commit 65299ed

Browse files
committed
Re-add error handler.
1 parent 1ce7ab6 commit 65299ed

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/BedrockUpdater.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<OutputType>WinExe</OutputType>
3+
<OutputType>Exe</OutputType>
44
<TargetFramework>net481</TargetFramework>
55
<UseWindowsForms>true</UseWindowsForms>
66
<UseWPF>true</UseWPF>

src/MainWindow.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ internal MainWindow(bool preview)
3030
WindowStartupLocation = WindowStartupLocation.CenterScreen;
3131
ResizeMode = ResizeMode.NoResize;
3232
SizeToContent = SizeToContent.WidthAndHeight;
33+
Closed += (sender, e) => Environment.Exit(0);
3334

3435
WindowsFormsHost host = new()
3536
{

src/Program.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ static void Main(string[] args)
99
{
1010
using Mutex mutex = new(true, "C7B58EAD-356C-40A1-A145-7262C3C04D00", out bool createdNew);
1111
if (Environment.OSVersion.Version < new Version(10, 0, 19041, 0) || NativeMethods.IsOS(29) || !createdNew) return;
12+
AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
13+
{
14+
var exception = (Exception)e.ExceptionObject;
15+
while (exception.InnerException != null) exception = exception.InnerException;
16+
NativeMethods.ShellMessageBox(lpcText: exception.Message);
17+
Environment.Exit(0);
18+
};
1219
new MainWindow(args.FirstOrDefault()?.Equals("/preview", StringComparison.OrdinalIgnoreCase) ?? false).ShowDialog();
1320
}
1421
}

0 commit comments

Comments
 (0)