Skip to content

Commit

Permalink
Ensure InnerException is properly checked for DLL missing cases
Browse files Browse the repository at this point in the history
  • Loading branch information
soopercool101 committed May 12, 2023
1 parent 77683fa commit 886bc2c
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions BrawlCrate/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,28 @@ private static void Application_ThreadException(object sender, System.Threading.
{
List<ResourceNode> dirty = GetDirtyFiles();
Exception ex = e.Exception;
if (ExceptionIsDLLMissing(ex) || ExceptionIsDLLMissing(ex.InnerException))
{
if (CanRunGithubApp(false, out _))
{
MessageBox.Show(
"One or more key installation files are missing, likely due to antivirus software. The latest version will now be reinstalled. Please add your installation folder to your antivirus's exceptions list.",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
#if CANARY
ForceDownloadCanary();
#else
ForceDownloadStable();
#endif
}
else
{
MessageBox.Show(
"One or more key installation files are missing, including the automatic updater. This is likely due to antivirus software. Please reinstall and add your installation folder to your antivirus's exceptions list.",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

return;
}
IssueDialog d = new IssueDialog(ex, dirty);
d.ShowDialog();
d.Dispose();
Expand All @@ -309,7 +331,7 @@ private static void CurrentDomain_UnhandledException(object sender, UnhandledExc
{
if (e.ExceptionObject is Exception ex)
{
if (ExceptionIsDLLMissing(ex))
if (ExceptionIsDLLMissing(ex) || ExceptionIsDLLMissing(ex.InnerException))
{
if (CanRunGithubApp(false, out _))
{
Expand Down Expand Up @@ -510,7 +532,7 @@ public static void Main(string[] args)

Application.Run(MainForm.Instance);
}
catch(Exception x)
catch(FileNotFoundException x)
{
throw x; // This is necessary to catch DLL errors properly
}
Expand Down

0 comments on commit 886bc2c

Please sign in to comment.