Selaa lähdekoodia

Improve error handling when attempting to load very old plugin assemblies

Luke Pulverenti 8 vuotta sitten
vanhempi
sitoutus
975a973d31
2 muutettua tiedostoa jossa 14 lisäystä ja 4 poistoa
  1. 13 3
      Emby.Common.Implementations/BaseApplicationHost.cs
  2. 1 1
      SharedVersion.cs

+ 13 - 3
Emby.Common.Implementations/BaseApplicationHost.cs

@@ -560,12 +560,15 @@ namespace Emby.Common.Implementations
         {
             if (assembly == null)
             {
-                throw new ArgumentNullException("assembly");
+                return new List<Type>();
             }
 
             try
             {
-                return assembly.GetTypes();
+                // This null checking really shouldn't be needed but adding it due to some
+                // unhandled exceptions in mono 5.0 that are a little hard to hunt down
+                var types = assembly.GetTypes() ?? new Type[] { };
+                return types.Where(t => t != null);
             }
             catch (ReflectionTypeLoadException ex)
             {
@@ -578,7 +581,14 @@ namespace Emby.Common.Implementations
                 }
 
                 // If it fails we can still get a list of the Types it was able to resolve
-                return ex.Types.Where(t => t != null);
+                var types = ex.Types ?? new Type[] { };
+                return types.Where(t => t != null);
+            }
+            catch (Exception ex)
+            {
+                Logger.ErrorException("Error loading types from assembly", ex);
+
+                return new List<Type>();
             }
         }
 

+ 1 - 1
SharedVersion.cs

@@ -1,3 +1,3 @@
 using System.Reflection;
 
-[assembly: AssemblyVersion("3.2.24.0")]
+[assembly: AssemblyVersion("3.2.25.0")]