Skip to content

Commit b9fe507

Browse files
committed
Use Assembly.LoadFrom for loading assemblies
Assembly.LoadFile is meant for a special case that is not relevant to BepInEx
1 parent c0b9eae commit b9fe507

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

BepInEx.Core/Bootstrap/BaseChainloader.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ protected static bool PluginTargetsWrongBepin(PluginInfo pluginInfo)
125125
/// Contains information about what certain plugins were not loaded.
126126
/// </summary>
127127
public List<string> DependencyErrors { get; } = new();
128-
128+
129129
/// <summary>
130130
/// Occurs after a plugin is loaded.
131131
/// </summary>
@@ -404,7 +404,7 @@ static bool IsHardDependency(BepInDependency dep) =>
404404
Logger.Log(LogLevel.Info, $"Loading [{plugin}]");
405405

406406
if (!loadedAssemblies.TryGetValue(plugin.Location, out var ass))
407-
loadedAssemblies[plugin.Location] = ass = Assembly.LoadFile(plugin.Location);
407+
loadedAssemblies[plugin.Location] = ass = Assembly.LoadFrom(plugin.Location);
408408

409409
Plugins[plugin.Metadata.GUID] = plugin;
410410
TryRunModuleCtor(plugin, ass);

BepInEx.Core/Utility.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ public static bool IsSubtypeOf(this TypeDefinition self, Type td)
242242
/// <param name="assembly">The loaded assembly.</param>
243243
/// <returns>True, if the assembly was found and loaded. Otherwise, false.</returns>
244244
public static bool TryResolveDllAssembly(AssemblyName assemblyName, string directory, out Assembly assembly) =>
245-
TryResolveDllAssembly(assemblyName, directory, Assembly.LoadFile, out assembly);
245+
TryResolveDllAssembly(assemblyName, directory, Assembly.LoadFrom, out assembly);
246246

247247
/// <summary>
248248
/// Try to resolve and load the given assembly DLL.

Runtimes/NET/BepInEx.NET.Shared/SharedEntrypoint.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,6 @@ private static bool TryResolveDllAssembly<T>(AssemblyName assemblyName,
139139
/// <param name="assembly">The loaded assembly.</param>
140140
/// <returns>True, if the assembly was found and loaded. Otherwise, false.</returns>
141141
public static bool TryResolveDllAssembly(AssemblyName assemblyName, string directory, out Assembly assembly) =>
142-
TryResolveDllAssembly(assemblyName, directory, Assembly.LoadFile, out assembly);
142+
TryResolveDllAssembly(assemblyName, directory, Assembly.LoadFrom, out assembly);
143143
}
144144
}

0 commit comments

Comments
 (0)