diff --git a/docs/release-notes.md b/docs/release-notes.md index e71457af..a00c73da 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -3,6 +3,7 @@ # Release notes ## Upcoming release * For players: + * Added friendly error in 64-bit mode when a mod is 32-bit only. * Fixed some installer errors now show info header. * For mod authors: diff --git a/src/SMAPI.Toolkit/Framework/LowLevelEnvironmentUtility.cs b/src/SMAPI.Toolkit/Framework/LowLevelEnvironmentUtility.cs index be0c18ce..2636aae0 100644 --- a/src/SMAPI.Toolkit/Framework/LowLevelEnvironmentUtility.cs +++ b/src/SMAPI.Toolkit/Framework/LowLevelEnvironmentUtility.cs @@ -90,10 +90,10 @@ namespace StardewModdingAPI.Toolkit.Framework } /// Get whether an executable is 64-bit. - /// The absolute path to the executable file. - public static bool Is64BitAssembly(string executablePath) + /// The absolute path to the assembly file. + public static bool Is64BitAssembly(string path) { - return AssemblyName.GetAssemblyName(executablePath).ProcessorArchitecture != ProcessorArchitecture.X86; + return AssemblyName.GetAssemblyName(path).ProcessorArchitecture != ProcessorArchitecture.X86; } diff --git a/src/SMAPI.Toolkit/Utilities/EnvironmentUtility.cs b/src/SMAPI.Toolkit/Utilities/EnvironmentUtility.cs index 62bd13cd..6de79a85 100644 --- a/src/SMAPI.Toolkit/Utilities/EnvironmentUtility.cs +++ b/src/SMAPI.Toolkit/Utilities/EnvironmentUtility.cs @@ -46,5 +46,12 @@ namespace StardewModdingAPI.Toolkit.Utilities { return LowLevelEnvironmentUtility.GetExecutableName(platform.ToString()); } + + /// Get whether an executable is 64-bit. + /// The absolute path to the assembly file. + public static bool Is64BitAssembly(string path) + { + return LowLevelEnvironmentUtility.Is64BitAssembly(path); + } } } diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs index 5fb4aa03..dff0fc55 100644 --- a/src/SMAPI/Framework/SCore.cs +++ b/src/SMAPI/Framework/SCore.cs @@ -1704,12 +1704,21 @@ namespace StardewModdingAPI.Framework // load as mod else { + // get mod info IManifest manifest = mod.Manifest; + string assemblyPath = Path.Combine(mod.DirectoryPath, manifest.EntryDll); + + // assert 64-bit +#if SMAPI_FOR_WINDOWS_64BIT_HACK + if (!EnvironmentUtility.Is64BitAssembly(assemblyPath)) + { + errorReasonPhrase = "it needs to be updated for 64-bit mode."; + failReason = ModFailReason.LoadFailed; + return false; + } +#endif // load mod - string assemblyPath = manifest?.EntryDll != null - ? Path.Combine(mod.DirectoryPath, manifest.EntryDll) - : null; Assembly modAssembly; try {