adds Serilog to implement logging to file. Later users may attach these files to issues
adds exception logging to existing try-catch'es where possible
adds error logging to OnDispatcherUnhandledException
I suspect, that app crash in these 2 issues occures due to uncacthed exception in async void methods. Modifiying CheckForUpdate in App.xaml.cs like this leads to similar behavour
public static async void CheckForUpdate()
{
var updateManager = new UpdateManager("JamesCJ60", "Universal-x86-Tuning-Utility", App.version, "C:\\");
var isUpdateAvailable = await updateManager.IsUpdateAvailable();
if (isUpdateAvailable)
{
ToastNotification.ShowToastNotification("New Update Available!", $"Head to the settings menu to easily download the new Universal x86 Tuning Utility update!");
}
throw new Exception("Boom!");
}
If my guess is correct, such exceptions will be intecepted in OnDispatcherUnhandledException and logged like this (and if I'm incorrect, logging still will be useful)
2024-04-07 17:24:21.845 +03:00 [INF] Application started. Press Ctrl+C to shut down.
2024-04-07 17:24:21.881 +03:00 [INF] Hosting environment: Production
2024-04-07 17:24:21.882 +03:00 [INF] Content root path: C:\Users\maxim\RiderProjects\Universal-x86-Tuning-Utility\Universal x86 Tuning Utility\bin\Debug\net8.0-windows10.0.22621.0
2024-04-07 17:24:22.402 +03:00 [FTL] Unhandled dispatcher exception
System.Exception: Boom!
at Universal_x86_Tuning_Utility.App.CheckForUpdate() in C:\Users\maxim\RiderProjects\Universal-x86-Tuning-Utility\Universal x86 Tuning Utility\App.xaml.cs:line 280
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
There are 2 similar issues https://github.com/JamesCJ60/Universal-x86-Tuning-Utility/issues/185 and https://github.com/JamesCJ60/Universal-x86-Tuning-Utility/issues/186, that quite hard to investiage due to lack of useful infromation. Changes in this PR should make troubleshooting easier:
I suspect, that app crash in these 2 issues occures due to uncacthed exception in
async void
methods. ModifiyingCheckForUpdate
inApp.xaml.cs
like this leads to similar behavourIf my guess is correct, such exceptions will be intecepted in
OnDispatcherUnhandledException
and logged like this (and if I'm incorrect, logging still will be useful)