From 5e03954afe9cbea9a8eeb2c19f441f2c29bb3c3e Mon Sep 17 00:00:00 2001 From: MapleWheels Date: Fri, 22 Sep 2023 11:56:12 -0400 Subject: [PATCH] Added threading controls to AppDomain type search. --- .../LuaCs/Plugins/AssemblyManager.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Plugins/AssemblyManager.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Plugins/AssemblyManager.cs index 13fccff71..b68a8e6b7 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Plugins/AssemblyManager.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Plugins/AssemblyManager.cs @@ -236,12 +236,20 @@ public partial class AssemblyManager if (types.Count > 0) return types; - // fallback to Type.GetType - foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) + OpsLockLoaded.EnterReadLock(); + try { - Type t = assembly.GetType(typeName); - if (t is not null) - types.Add(byRef ? t.MakeByRefType() : t); + // fallback to Type.GetType + foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) + { + Type t = assembly.GetType(typeName, false, false); + if (t is not null) + types.Add(byRef ? t.MakeByRefType() : t); + } + } + finally + { + OpsLockLoaded.ExitReadLock(); } return types;