mirror of
https://github.com/kwsch/PKHeX
synced 2024-09-20 22:32:00 +00:00
Add Framework check for non-windows OS
GetFrameworkVersion() throws an System.NullReferenceException since there is no Registry on non-windows systems. Fixed by checking the OS under which the program runs. If it's not Windows, check the CLR Version instead of querying the (non-existant) registry.
This commit is contained in:
parent
41d8cc96ca
commit
cf9bf85bb4
1 changed files with 37 additions and 10 deletions
|
@ -29,16 +29,33 @@ namespace PKHeX.WinForms
|
|||
|
||||
try
|
||||
{
|
||||
if (GetFrameworkVersion() >= 393295)
|
||||
{
|
||||
StartPKHeX();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Todo: make this translatable
|
||||
MessageBox.Show(".NET Framework 4.6 needs to be installed for this version of PKHeX to run.", "PKHeX Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
||||
Process.Start(@"https://www.microsoft.com/download/details.aspx?id=48130");
|
||||
}
|
||||
if (IsOnWindows())
|
||||
{
|
||||
if (GetFrameworkVersion() >= 393295)
|
||||
{
|
||||
StartPKHeX();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Todo: make this translatable
|
||||
MessageBox.Show(".NET Framework 4.6 needs to be installed for this version of PKHeX to run.", "PKHeX Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
||||
Process.Start(@"https://www.microsoft.com/download/details.aspx?id=48130");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//CLR Version 4.0.30319 is equivalent to .NET Framework version 4.6
|
||||
if ((Environment.Version.CompareTo(Version.Parse("4.0.30319.42000"))) >= 0)
|
||||
{
|
||||
StartPKHeX();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Your version of Mono needs to target the .NET Framework 4.6 or higher for this version of PKHeX to run.",
|
||||
"PKHeX Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
|
@ -63,6 +80,16 @@ namespace PKHeX.WinForms
|
|||
Application.Run(new Main());
|
||||
}
|
||||
|
||||
public static bool IsOnWindows()
|
||||
{
|
||||
// 4 -> UNIX, 6 -> Mac OSX, 128 -> UNIX (old)
|
||||
int p = (int)Environment.OSVersion.Platform;
|
||||
if ((p == 4) || (p == 6) || (p == 128))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static int GetFrameworkVersion()
|
||||
{
|
||||
const string subkey = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\";
|
||||
|
|
Loading…
Reference in a new issue