Fix plugin dependencies not getting loaded

This commit is contained in:
Stone_Red
2024-05-01 15:51:19 +02:00
parent ca9f426bba
commit 5804bade47
2 changed files with 2 additions and 2 deletions
+1
View File
@@ -9,3 +9,4 @@ using System.Diagnostics.CodeAnalysis;
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "No need to")] [assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "No need to")]
[assembly: SuppressMessage("Minor Code Smell", "S1075:URIs should not be hardcoded", Justification = "<Pending>")] [assembly: SuppressMessage("Minor Code Smell", "S1075:URIs should not be hardcoded", Justification = "<Pending>")]
[assembly: SuppressMessage("Critical Code Smell", "S2696:Instance members should not write to \"static\" fields", Justification = "<Pending>", Scope = "member", Target = "~P:DesktopMagic.DataContexts.MainWindowDataContext.Settings")] [assembly: SuppressMessage("Critical Code Smell", "S2696:Instance members should not write to \"static\" fields", Justification = "<Pending>", Scope = "member", Target = "~P:DesktopMagic.DataContexts.MainWindowDataContext.Settings")]
[assembly: SuppressMessage("Major Code Smell", "S3885:\"Assembly.Load\" should be used", Justification = "Assembly.Load does not load dependencies", Scope = "member", Target = "~M:DesktopMagic.PluginWindow.ExecuteSource")]
@@ -202,8 +202,7 @@ public partial class PluginWindow : Window
object? instance = pluginClassInstance; object? instance = pluginClassInstance;
if (instance is null) if (instance is null)
{ {
byte[] assemblyBytes = File.ReadAllBytes($"{PluginFolderPath}\\main.dll"); Assembly dll = Assembly.LoadFrom($"{PluginFolderPath}\\main.dll");
Assembly dll = Assembly.Load(assemblyBytes);
Type? instanceType = Array.Find(dll.GetTypes(), type => type.GetTypeInfo().BaseType == typeof(Plugin)); Type? instanceType = Array.Find(dll.GetTypes(), type => type.GetTypeInfo().BaseType == typeof(Plugin));
if (instanceType is null) if (instanceType is null)