From 5303a93a3d90fb141a6c102a64de9b4436e67ae8 Mon Sep 17 00:00:00 2001 From: Raymond Date: Sun, 22 Aug 2021 08:03:22 -0400 Subject: [PATCH] Fail gracefully for IDalamudPlugin check failures --- Dalamud/Plugin/Internal/LocalPlugin.cs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Dalamud/Plugin/Internal/LocalPlugin.cs b/Dalamud/Plugin/Internal/LocalPlugin.cs index 82240b2dd..f7b7112ce 100644 --- a/Dalamud/Plugin/Internal/LocalPlugin.cs +++ b/Dalamud/Plugin/Internal/LocalPlugin.cs @@ -55,13 +55,6 @@ namespace Dalamud.Plugin.Internal { // BadImageFormatException this.pluginAssembly = this.loader.LoadDefaultAssembly(); - - // InvalidOperationException - this.pluginType = this.pluginAssembly.GetTypes().FirstOrDefault(type => type.IsAssignableTo(typeof(IDalamudPlugin))); - if (this.pluginType == default) - throw new Exception("Nothing inherits from IDalamudPlugin"); - - assemblyVersion = this.pluginAssembly.GetName().Version; } catch (Exception ex) { @@ -73,6 +66,19 @@ namespace Dalamud.Plugin.Internal throw new InvalidPluginException(this.DllFile); } + this.pluginType = this.pluginAssembly.GetTypes().FirstOrDefault(type => type.IsAssignableTo(typeof(IDalamudPlugin))); + if (this.pluginType == default) + { + this.pluginAssembly = null; + this.pluginType = null; + this.loader.Dispose(); + + Log.Error($"Nothing inherits from IDalamudPlugin: {this.DllFile.Name}"); + throw new InvalidPluginException(this.DllFile); + } + + assemblyVersion = this.pluginAssembly.GetName().Version; + // Files that may or may not exist this.manifestFile = LocalPluginManifest.GetManifestFile(this.DllFile); this.disabledFile = LocalPluginManifest.GetDisabledFile(this.DllFile);