diff --git a/BizHawk.Client.EmuHawk/tools/ToolManager.cs b/BizHawk.Client.EmuHawk/tools/ToolManager.cs index 9a382d2d11..0fa81dc2e4 100644 --- a/BizHawk.Client.EmuHawk/tools/ToolManager.cs +++ b/BizHawk.Client.EmuHawk/tools/ToolManager.cs @@ -739,17 +739,26 @@ namespace BizHawk.Client.EmuHawk } } - private static readonly Lazy> lazyAsmTypes = new Lazy>(() => - Assembly.ReflectionOnlyLoadFrom(Assembly.GetExecutingAssembly().Location) - .GetTypes() - .Select(t => t.AssemblyQualifiedName) - .ToList() + private static readonly Lazy> _lazyAsmTypes = new Lazy>(() => + new HashSet(GetAssemblyTypes().Select(t => t.AssemblyQualifiedName)) ); + private static Type[] GetAssemblyTypes() + { + try + { + return Assembly.ReflectionOnlyLoadFrom(Assembly.GetExecutingAssembly().Location).GetTypes(); + } + catch (ReflectionTypeLoadException ex) + { + throw new AggregateException(ex.LoaderExceptions); + } + } + public bool IsAvailable(Type tool) { if (!ServiceInjector.IsAvailable(Global.Emulator.ServiceProvider, tool) - || !lazyAsmTypes.Value.Contains(tool.AssemblyQualifiedName) // not a tool + || !_lazyAsmTypes.Value.Contains(tool.AssemblyQualifiedName) // not a tool || (tool == typeof(LuaConsole) && OSTailoredCode.CurrentOS != OSTailoredCode.DistinctOS.Windows)) // simply doesn't work (for now) { return false;