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);