Browse Source

Fixed failing to load a plugin if any type inherits a type from a missing assembly

ManlyMarco 5 years ago
parent
commit
bb7000ae1a
1 changed files with 12 additions and 1 deletions
  1. 12 1
      BepInEx/Bootstrap/Chainloader.cs

+ 12 - 1
BepInEx/Bootstrap/Chainloader.cs

@@ -93,9 +93,20 @@ namespace BepInEx.Bootstrap
 
 		public static PluginInfo ToPluginInfo(TypeDefinition type)
 		{
-			if (type.IsInterface || type.IsAbstract || !type.IsSubtypeOf(typeof(BaseUnityPlugin)))
+			if (type.IsInterface || type.IsAbstract)
 				return null;
 
+			try
+			{
+				if (!type.IsSubtypeOf(typeof(BaseUnityPlugin)))
+					return null;
+			}
+			catch (AssemblyResolutionException)
+			{
+				// Can happen if this type inherits a type from an assembly that can't be found. Safe to assume it's not a plugin.
+				return null;
+			}
+
 			var metadata = BepInPlugin.FromCecilType(type);
 
 			// Perform checks that will prevent the plugin from being loaded in ALL cases