diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2016-12-02 17:15:52 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2016-12-02 17:15:52 -0500 |
commit | ad773a947acaf02b472846bc3eefdac2e514a1a7 (patch) | |
tree | 013ee0ff21b928e696e7815b00fe477aff9a0db2 /src/StardewModdingAPI/Framework/ModAssemblyLoader.cs | |
parent | 67feb7e9a9ee057fdfb5b30840970b3952048b45 (diff) | |
download | SMAPI-ad773a947acaf02b472846bc3eefdac2e514a1a7.tar.gz SMAPI-ad773a947acaf02b472846bc3eefdac2e514a1a7.tar.bz2 SMAPI-ad773a947acaf02b472846bc3eefdac2e514a1a7.zip |
fix assembly resolution when mods try to load types from other mods (#166)
Diffstat (limited to 'src/StardewModdingAPI/Framework/ModAssemblyLoader.cs')
-rw-r--r-- | src/StardewModdingAPI/Framework/ModAssemblyLoader.cs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/StardewModdingAPI/Framework/ModAssemblyLoader.cs b/src/StardewModdingAPI/Framework/ModAssemblyLoader.cs index c5f9ec31..d92a04f3 100644 --- a/src/StardewModdingAPI/Framework/ModAssemblyLoader.cs +++ b/src/StardewModdingAPI/Framework/ModAssemblyLoader.cs @@ -103,10 +103,19 @@ namespace StardewModdingAPI.Framework } /// <summary>Resolve an assembly from its name.</summary> - /// <param name="shortName">The short assembly name.</param> - public Assembly ResolveAssembly(string shortName) + /// <param name="name">The assembly name.</param> + /// <remarks> + /// This implementation returns the first loaded assembly which matches the short form of + /// the assembly name, to resolve assembly resolution issues when rewriting + /// assemblies (especially with Mono). Since this is meant to be called on <see cref="AppDomain.AssemblyResolve"/>, + /// the implicit assumption is that loading the exact assembly failed. + /// </remarks> + public Assembly ResolveAssembly(string name) { - return this.AssemblyMap.Targets.FirstOrDefault(p => p.GetName().Name == shortName); + string shortName = name.Split(new[] { ',' }, 2).First(); // get simple name (without version and culture) + return AppDomain.CurrentDomain + .GetAssemblies() + .FirstOrDefault(p => p.GetName().Name == shortName); } |