Skip to content

Commit

Permalink
Use Assembly.LoadFrom for loading assemblies
Browse files Browse the repository at this point in the history
Assembly.LoadFile is meant for a special case that is not relevant to BepInEx
  • Loading branch information
ghorsington committed Sep 11, 2022
1 parent c0b9eae commit b9fe507
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions BepInEx.Core/Bootstrap/BaseChainloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ protected static bool PluginTargetsWrongBepin(PluginInfo pluginInfo)
/// Contains information about what certain plugins were not loaded.
/// </summary>
public List<string> DependencyErrors { get; } = new();

/// <summary>
/// Occurs after a plugin is loaded.
/// </summary>
Expand Down Expand Up @@ -404,7 +404,7 @@ static bool IsHardDependency(BepInDependency dep) =>
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);
Expand Down
2 changes: 1 addition & 1 deletion BepInEx.Core/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public static bool IsSubtypeOf(this TypeDefinition self, Type td)
/// <param name="assembly">The loaded assembly.</param>
/// <returns>True, if the assembly was found and loaded. Otherwise, false.</returns>
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);

/// <summary>
/// Try to resolve and load the given assembly DLL.
Expand Down
2 changes: 1 addition & 1 deletion Runtimes/NET/BepInEx.NET.Shared/SharedEntrypoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,6 @@ private static bool TryResolveDllAssembly<T>(AssemblyName assemblyName,
/// <param name="assembly">The loaded assembly.</param>
/// <returns>True, if the assembly was found and loaded. Otherwise, false.</returns>
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);
}
}

0 comments on commit b9fe507

Please sign in to comment.