不久前我已经切换到Catel for IoC,但是当我要并行运行单元测试时,我从卡特尔内部深陷GetTypesEx的死锁。
堆栈跟踪如下:
Catel.Core.dll!Catel.Reflection.ReflectionExtensions.GetTypesEx(System.Reflection.Assembly组装)40行C# Catel.Core.dll!Catel.Reflection.AssemblyHelper.GetAllTypesSafely(System.Reflection.Assembly程序集,bool logLoaderExceptions)行155 C# Catel.Core.dll!Catel.Reflection.TypeCache.GetAssemblyTypes.AnonymousMethod__42_1(System.Reflection.Assembly组装)829行C# System.Core.dll!System.Linq.Enumerable.WhereSelectListIterator >>。MoveNext()未知 System.Core.dll!System.Linq.ParallelEnumerable.ToDictionary>,System.Reflection.Assembly,System.Collections.Generic.HashSet>(System.Linq.ParallelQuery >>源,System.Func>,System.Reflection.Assembly> keySelector,System.Func>,System.Collections.Generic.HashSet> elementSelector,System.Collections.Generic.IEqualityComparer比较器)未知 Catel.Core.dll!Catel.Reflection.TypeCache.GetAssemblyTypes(System.Collections.Generic.List程序集,bool allowMultithreadedInitialization)行836 C# Catel.Core.dll!Catel.Reflection.TypeCache.InitializeAssemblies(System.Collections.Generic.IEnumerable程序集,bool force,bool allowMultithreadedInitialization)行711 C# Catel.Core.dll!Catel.Reflection.TypeCache.InitializeTypes(System.Reflection.Assembly组装,bool forceFullInitialization,bool allowMultithreadedInitialization)行674 C# Catel.Core.dll!Catel.Reflection.TypeCache.TypeCache()第113行C# [从本地过渡到托管过渡]
[已完成向本地的过渡]
Catel.Core.dll!Catel.HttpContextHelper.GetHttpContext()第26行C# Catel.Core.dll!Catel.Core.ModuleInitializer.GetExeConfiguration()行80 C# Catel.Core.dll!Catel.Core.ModuleInitializer.Initialize()行41 C# Catel.Core.dll!。()未知 [从本地过渡到托管过渡]
[已完成向本地的过渡]
PluginTests.dll!PluginTests.AcquisitionPlugin.InitServiceManager(Microsoft.VisualStudio.TestTools.UnitTesting.TestContext上下文)第103行C#
有什么想法可以避免这种情况吗? 我不知道从根本上做错什么。我正在使用类初始化方法(使用MStest 2)注册我的类型
答案 0 :(得分:0)
您可以尝试先初始化TypeCache:
TypeCache.InitializeTypes(allowMultithreadedInitialization: false);
但更好的是:报告一张票(最好是带有repro!),以便Catel团队可以解决此问题。