Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
Fixed assembly loading resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
Aragas committed Oct 27, 2022
1 parent 03740ff commit 027ffd2
Showing 1 changed file with 2 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@
using System.Reflection;
using System.Runtime.CompilerServices;

using TaleWorlds.Engine;
using TaleWorlds.Library;

using Path = System.IO.Path;

namespace Bannerlord.BUTRLoader.Features.AssemblyResolver.Patches
{
internal static class AssemblyLoaderPatch
Expand All @@ -33,16 +30,10 @@ private static bool OnAssemblyResolvePrefix(ref Assembly? __result, ResolveEvent
{
try
{
var basePath = Utilities.GetBasePath();
var configName = Common.ConfigName;
var modulePath = Path.GetFullPath(Path.Combine(basePath, "Modules"));

var name = args.Name.Contains(',') ? $"{args.Name.Split(',')[0]}.dll" : args.Name;

var assemblies = ModuleInfoHelper.GetLoadedModules()
.Select(x => Path.Combine(modulePath, x.Id, "bin", configName))
.Where(Directory.Exists)
.Select(x => Directory.GetFiles(x, "*.dll")).ToArray();
var assemblies = ModuleInfoHelper.GetLoadedModules().OfType<ModuleInfoExtendedWithMetadata>()
.Select(x => Directory.GetFiles(x.Path, "*.dll")).ToArray();

var assembly = assemblies
.SelectMany(x => x)
Expand Down

0 comments on commit 027ffd2

Please sign in to comment.