add error if some SMAPI DLLs have mismatched versions
This commit is contained in:
parent
c74702b027
commit
7e5d77fb8c
|
@ -9,7 +9,8 @@
|
||||||
|
|
||||||
## Upcoming release
|
## Upcoming release
|
||||||
* For players:
|
* For players:
|
||||||
* Added error message if you manually install the wrong SMAPI bitness (e.g. 32-bit SMAPI with 64-bit game).
|
* Added error if the wrong SMAPI bitness is installed (e.g. 32-bit SMAPI with 64-bit game).
|
||||||
|
* Added error if some SMAPI files aren't updated correctly.
|
||||||
* Fixed intermittent error if a mod fetches mod-provided APIs asynchronously.
|
* Fixed intermittent error if a mod fetches mod-provided APIs asynchronously.
|
||||||
|
|
||||||
* For mod authors:
|
* For mod authors:
|
||||||
|
|
|
@ -5,6 +5,7 @@ using System.Reflection;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using StardewModdingAPI.Framework;
|
using StardewModdingAPI.Framework;
|
||||||
using StardewModdingAPI.Toolkit.Framework;
|
using StardewModdingAPI.Toolkit.Framework;
|
||||||
|
using StardewModdingAPI.Toolkit.Serialization.Models;
|
||||||
|
|
||||||
namespace StardewModdingAPI
|
namespace StardewModdingAPI
|
||||||
{
|
{
|
||||||
|
@ -32,6 +33,7 @@ namespace StardewModdingAPI
|
||||||
AppDomain.CurrentDomain.AssemblyResolve += Program.CurrentDomain_AssemblyResolve;
|
AppDomain.CurrentDomain.AssemblyResolve += Program.CurrentDomain_AssemblyResolve;
|
||||||
Program.AssertGamePresent();
|
Program.AssertGamePresent();
|
||||||
Program.AssertGameVersion();
|
Program.AssertGameVersion();
|
||||||
|
Program.AssertSmapiVersions();
|
||||||
Program.Start(args);
|
Program.Start(args);
|
||||||
}
|
}
|
||||||
catch (BadImageFormatException ex) when (ex.FileName == "StardewValley" || ex.FileName == "Stardew Valley") // don't use EarlyConstants.GameAssemblyName, since we want to check both possible names
|
catch (BadImageFormatException ex) when (ex.FileName == "StardewValley" || ex.FileName == "Stardew Valley") // don't use EarlyConstants.GameAssemblyName, since we want to check both possible names
|
||||||
|
@ -122,6 +124,20 @@ namespace StardewModdingAPI
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Assert that the versions of all SMAPI components are correct.</summary>
|
||||||
|
/// <remarks>Players sometimes have mismatched versions (particularly when installed through Vortex), which can cause some very confusing bugs without this check.</remarks>
|
||||||
|
private static void AssertSmapiVersions()
|
||||||
|
{
|
||||||
|
// SMAPI toolkit
|
||||||
|
foreach (var type in new[] { typeof(IManifest), typeof(Manifest) })
|
||||||
|
{
|
||||||
|
Assembly assembly = type.Assembly;
|
||||||
|
var assemblyVersion = new SemanticVersion(assembly.GetName().Version);
|
||||||
|
if (!assemblyVersion.Equals(Constants.ApiVersion))
|
||||||
|
Program.PrintErrorAndExit($"Oops! The 'smapi-internal/{assembly.GetName().Name}.dll' file is version {assemblyVersion} instead of the required {Constants.ApiVersion}. SMAPI doesn't seem to be installed correctly.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Initialize SMAPI and launch the game.</summary>
|
/// <summary>Initialize SMAPI and launch the game.</summary>
|
||||||
/// <param name="args">The command-line arguments.</param>
|
/// <param name="args">The command-line arguments.</param>
|
||||||
/// <remarks>This method is separate from <see cref="Main"/> because that can't contain any references to assemblies loaded by <see cref="CurrentDomain_AssemblyResolve"/> (e.g. via <see cref="Constants"/>), or Mono will incorrectly show an assembly resolution error before assembly resolution is set up.</remarks>
|
/// <remarks>This method is separate from <see cref="Main"/> because that can't contain any references to assemblies loaded by <see cref="CurrentDomain_AssemblyResolve"/> (e.g. via <see cref="Constants"/>), or Mono will incorrectly show an assembly resolution error before assembly resolution is set up.</remarks>
|
||||||
|
|
Loading…
Reference in New Issue