diff --git a/ArchiSteamFarm/Core/ASF.cs b/ArchiSteamFarm/Core/ASF.cs index 0e0b31d8c1288..19a0ed329d729 100644 --- a/ArchiSteamFarm/Core/ASF.cs +++ b/ArchiSteamFarm/Core/ASF.cs @@ -438,13 +438,23 @@ private static void LoadAllAssemblies() { private static void LoadAssembliesNeededBeforeUpdate() { HashSet loadedAssembliesNames = GetLoadedAssembliesNames(); - foreach (Assembly assembly in AssembliesNeededBeforeUpdate.Where(assemblyName => !loadedAssembliesNames.Contains(assemblyName)).Select(Assembly.Load)) { + foreach (string assemblyName in AssembliesNeededBeforeUpdate.Where(loadedAssembliesNames.Add)) { + Assembly assembly; + + try { + assembly = Assembly.Load(assemblyName); + } catch (Exception e) { + ArchiLogger.LogGenericDebuggingException(e); + + continue; + } + LoadAssembliesRecursively(assembly, loadedAssembliesNames); } } [UnconditionalSuppressMessage("AssemblyLoadTrimming", "IL2026:RequiresUnreferencedCode", Justification = "We don't care about trimmed assemblies, as we need it to work only with the known (used) ones")] - private static void LoadAssembliesRecursively(Assembly assembly, ICollection loadedAssembliesNames) { + private static void LoadAssembliesRecursively(Assembly assembly, ISet loadedAssembliesNames) { if (assembly == null) { throw new ArgumentNullException(nameof(assembly)); } @@ -453,10 +463,18 @@ private static void LoadAssembliesRecursively(Assembly assembly, ICollection !loadedAssembliesNames.Contains(assemblyName.FullName))) { - loadedAssembliesNames.Add(assemblyName.FullName); + foreach (AssemblyName assemblyName in assembly.GetReferencedAssemblies().Where(assemblyName => loadedAssembliesNames.Add(assemblyName.FullName))) { + Assembly loadedAssembly; + + try { + loadedAssembly = Assembly.Load(assemblyName); + } catch (Exception e) { + ArchiLogger.LogGenericDebuggingException(e); + + continue; + } - LoadAssembliesRecursively(Assembly.Load(assemblyName), loadedAssembliesNames); + LoadAssembliesRecursively(loadedAssembly, loadedAssembliesNames); } }