From 69096c440a8b2bc0e499bd872f86930058e39085 Mon Sep 17 00:00:00 2001 From: marzent Date: Mon, 1 Jan 2024 01:20:00 +0100 Subject: [PATCH] Allow plugins to load Dalamud dependency assemblies (#1580) --- Dalamud/Plugin/Internal/Loader/PluginLoader.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Dalamud/Plugin/Internal/Loader/PluginLoader.cs b/Dalamud/Plugin/Internal/Loader/PluginLoader.cs index 5c03c32b8..53aec60ef 100644 --- a/Dalamud/Plugin/Internal/Loader/PluginLoader.cs +++ b/Dalamud/Plugin/Internal/Loader/PluginLoader.cs @@ -1,7 +1,7 @@ // Copyright (c) Nate McMaster, Dalamud team. // Licensed under the Apache License, Version 2.0. See License.txt in the Loader root for license information. -using System; +using System.IO; using System.Reflection; using System.Runtime.Loader; @@ -151,6 +151,14 @@ internal class PluginLoader : IDisposable builder.PreferDefaultLoadContextAssembly(assemblyName); } + // This allows plugins to search for dependencies in the Dalamud directory when their assembly + // load would otherwise fail, allowing them to resolve assemblies not already loaded by Dalamud + // itself yet. + builder.AddProbingPath(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); + + // Also make sure that plugins do not load their own Dalamud assembly. + builder.PreferDefaultLoadContextAssembly(Assembly.GetExecutingAssembly().GetName()); + return builder; }