Skip to content

Commit

Permalink
Improve error handling when attempting to load very old plugin assemb…
Browse files Browse the repository at this point in the history
…lies
  • Loading branch information
LukePulverenti committed Jul 10, 2017
1 parent 3907643 commit 19bfb86
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 13 additions & 3 deletions Emby.Common.Implementations/BaseApplicationHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -560,12 +560,15 @@ protected IEnumerable<Type> GetTypes(Assembly assembly)
{
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)
{
Expand All @@ -578,7 +581,14 @@ protected IEnumerable<Type> GetTypes(Assembly assembly)
}

// 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>();
}
}

Expand Down
2 changes: 1 addition & 1 deletion SharedVersion.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
using System.Reflection;

[assembly: AssemblyVersion("3.2.24.0")]
[assembly: AssemblyVersion("3.2.25.0")]

0 comments on commit 19bfb86

Please sign in to comment.