From 393ccb0ba6cd2e47c3103f3514b86ebf131f6842 Mon Sep 17 00:00:00 2001 From: Stone_Red <56473591+Stone-Red-Code@users.noreply.github.com> Date: Thu, 2 Jul 2026 15:09:26 +0200 Subject: [PATCH] Improve DLL dependency loading and fix plugin type check when loading plugin --- src/DesktopMagic/Plugins/PluginWindow.xaml.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/DesktopMagic/Plugins/PluginWindow.xaml.cs b/src/DesktopMagic/Plugins/PluginWindow.xaml.cs index ab73d77..a5e16f6 100644 --- a/src/DesktopMagic/Plugins/PluginWindow.xaml.cs +++ b/src/DesktopMagic/Plugins/PluginWindow.xaml.cs @@ -120,11 +120,10 @@ public partial class PluginWindow : Window, IPluginWindow string assemblyPath = Path.Combine(PluginFolderPath, assemblyName.Name + ".dll"); if (File.Exists(assemblyPath)) { - return ctx.LoadFromAssemblyPath(assemblyPath); - } - else - { - _ = ctx.LoadFromAssemblyName(assemblyName); + byte[] assemblyData = File.ReadAllBytes(assemblyPath); + using MemoryStream assemblyStream = new(assemblyData); + + return ctx.LoadFromStream(assemblyStream); } return null; }; @@ -483,7 +482,7 @@ public partial class PluginWindow : Window, IPluginWindow dll = Assembly.LoadFrom($"{PluginFolderPath}\\main.dll"); } - Type? instanceType = Array.Find(dll.GetTypes(), type => type.GetTypeInfo().BaseType == typeof(Plugin)); + Type? instanceType = Array.Find(dll.GetTypes(), type => type.IsAssignableTo(typeof(Plugin))); if (instanceType is null) {