mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-09-04 00:46:12 +02:00
Improve DLL dependency loading and fix plugin type check when loading plugin
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user