mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-26 22:10:21 +00:00
Handle non-.NET assemblies in dll plugins
Trycatch situations where people put libz3.dll in the plugins folder.
This commit is contained in:
parent
c66588666c
commit
c1eb70f57c
1 changed files with 13 additions and 3 deletions
|
@ -40,10 +40,20 @@ public static class PluginLoader
|
||||||
private static IEnumerable<Assembly> GetAssemblies(IEnumerable<string> dllFileNames, PluginLoadSetting loadSetting)
|
private static IEnumerable<Assembly> GetAssemblies(IEnumerable<string> dllFileNames, PluginLoadSetting loadSetting)
|
||||||
{
|
{
|
||||||
var loadMethod = GetPluginLoadMethod(loadSetting);
|
var loadMethod = GetPluginLoadMethod(loadSetting);
|
||||||
var assemblies = dllFileNames.Select(loadMethod);
|
foreach (var file in dllFileNames)
|
||||||
|
{
|
||||||
|
Assembly x;
|
||||||
|
try { x = loadMethod(file); }
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Debug.WriteLine($"Unable to load plugin from file: {file}");
|
||||||
|
Debug.WriteLine(ex.Message);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
yield return x;
|
||||||
|
}
|
||||||
if (loadSetting.IsMerged())
|
if (loadSetting.IsMerged())
|
||||||
assemblies = assemblies.Concat(new[] { Assembly.GetExecutingAssembly() }); // load merged too
|
yield return Assembly.GetExecutingAssembly(); // load merged too
|
||||||
return assemblies;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Func<string, Assembly> GetPluginLoadMethod(PluginLoadSetting pls) => pls switch
|
private static Func<string, Assembly> GetPluginLoadMethod(PluginLoadSetting pls) => pls switch
|
||||||
|
|
Loading…
Reference in a new issue