mirror of
https://github.com/Stone-Red-Code/DesktopMagic.git
synced 2026-09-07 15:56:13 +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");
|
string assemblyPath = Path.Combine(PluginFolderPath, assemblyName.Name + ".dll");
|
||||||
if (File.Exists(assemblyPath))
|
if (File.Exists(assemblyPath))
|
||||||
{
|
{
|
||||||
return ctx.LoadFromAssemblyPath(assemblyPath);
|
byte[] assemblyData = File.ReadAllBytes(assemblyPath);
|
||||||
}
|
using MemoryStream assemblyStream = new(assemblyData);
|
||||||
else
|
|
||||||
{
|
return ctx.LoadFromStream(assemblyStream);
|
||||||
_ = ctx.LoadFromAssemblyName(assemblyName);
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
@@ -483,7 +482,7 @@ public partial class PluginWindow : Window, IPluginWindow
|
|||||||
dll = Assembly.LoadFrom($"{PluginFolderPath}\\main.dll");
|
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)
|
if (instanceType is null)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user