Add check for old PKHeX.Core.dll (#2662)

This commit is contained in:
Evan Dixon 2020-01-26 10:55:13 -06:00 committed by Kurt
parent a3e9649f09
commit 4ef48a4e79

View File

@ -1,5 +1,6 @@
using System;
using System.Windows.Forms;
using System.Reflection;
#if !DEBUG
using System.IO;
using System.Threading;
@ -61,7 +62,11 @@ private static void CurrentDomain_UnhandledException(object sender, UnhandledExc
var ex = e.ExceptionObject as Exception;
try
{
if (ex != null)
if (IsOldPkhexCorePresent(ex))
{
Error("You have upgraded PKHeX incorrectly. Please delete PKHeX.Core.dll.");
}
else if (ex != null)
{
ErrorWindow.ShowErrorDialog("An unhandled exception has occurred.\nPKHeX must now close.", ex, false);
}
@ -114,6 +119,13 @@ private static bool EmergencyErrorLog(Exception originalException, Exception err
}
return true;
}
private static bool IsOldPkhexCorePresent(Exception ex)
{
return ex is MissingMethodException
&& File.Exists("PKHeX.Core.dll")
&& AssemblyName.GetAssemblyName("PKHeX.Core.dll").Version < Assembly.GetExecutingAssembly().GetName().Version;
}
#endif
}
}