From b9fe50767290ec8d133e836e9083af315a9d4551 Mon Sep 17 00:00:00 2001 From: ghorsington Date: Sun, 11 Sep 2022 18:41:22 +0300 Subject: [PATCH] Use Assembly.LoadFrom for loading assemblies Assembly.LoadFile is meant for a special case that is not relevant to BepInEx --- BepInEx.Core/Bootstrap/BaseChainloader.cs | 4 ++-- BepInEx.Core/Utility.cs | 2 +- Runtimes/NET/BepInEx.NET.Shared/SharedEntrypoint.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/BepInEx.Core/Bootstrap/BaseChainloader.cs b/BepInEx.Core/Bootstrap/BaseChainloader.cs index a0705af..c6fe182 100644 --- a/BepInEx.Core/Bootstrap/BaseChainloader.cs +++ b/BepInEx.Core/Bootstrap/BaseChainloader.cs @@ -125,7 +125,7 @@ public abstract class BaseChainloader /// Contains information about what certain plugins were not loaded. /// public List DependencyErrors { get; } = new(); - + /// /// Occurs after a plugin is loaded. /// @@ -404,7 +404,7 @@ public abstract class BaseChainloader Logger.Log(LogLevel.Info, $"Loading [{plugin}]"); if (!loadedAssemblies.TryGetValue(plugin.Location, out var ass)) - loadedAssemblies[plugin.Location] = ass = Assembly.LoadFile(plugin.Location); + loadedAssemblies[plugin.Location] = ass = Assembly.LoadFrom(plugin.Location); Plugins[plugin.Metadata.GUID] = plugin; TryRunModuleCtor(plugin, ass); diff --git a/BepInEx.Core/Utility.cs b/BepInEx.Core/Utility.cs index 0f73bd3..a6b93bd 100644 --- a/BepInEx.Core/Utility.cs +++ b/BepInEx.Core/Utility.cs @@ -242,7 +242,7 @@ public static class Utility /// The loaded assembly. /// True, if the assembly was found and loaded. Otherwise, false. public static bool TryResolveDllAssembly(AssemblyName assemblyName, string directory, out Assembly assembly) => - TryResolveDllAssembly(assemblyName, directory, Assembly.LoadFile, out assembly); + TryResolveDllAssembly(assemblyName, directory, Assembly.LoadFrom, out assembly); /// /// Try to resolve and load the given assembly DLL. diff --git a/Runtimes/NET/BepInEx.NET.Shared/SharedEntrypoint.cs b/Runtimes/NET/BepInEx.NET.Shared/SharedEntrypoint.cs index 819bcb9..47d9db8 100644 --- a/Runtimes/NET/BepInEx.NET.Shared/SharedEntrypoint.cs +++ b/Runtimes/NET/BepInEx.NET.Shared/SharedEntrypoint.cs @@ -139,6 +139,6 @@ namespace BepInEx.NET.Shared /// The loaded assembly. /// True, if the assembly was found and loaded. Otherwise, false. public static bool TryResolveDllAssembly(AssemblyName assemblyName, string directory, out Assembly assembly) => - TryResolveDllAssembly(assemblyName, directory, Assembly.LoadFile, out assembly); + TryResolveDllAssembly(assemblyName, directory, Assembly.LoadFrom, out assembly); } }