提交 4ab155a8 编写于 作者: J jaredpar

The CreateInstanceAndUnwrap call below is failing somewhat randomly in our...

   The CreateInstanceAndUnwrap call below is failing somewhat randomly in our test runs with an error claiming it can't load Roslyn.Test.Utilities.  So far we've been unable to actually catch this failure under a debugger because as previously stated the failure is random.  The only interesting data we have is that it's much more likely to fail in xUnit2 parallel mode than xUnit1.

     Looking at the code there seems to be an obvious explanation.  The Environment.CurrentDirectory value becomes the resolver path for the newly created AppDomain instance.  If this value doesn't point to the test binaries directory then it would explain the failure.  This is a process wide value that can easily be changed by other code.  Even if the code is careful to reset the value afterwards the intermediate value would be visible across AppDomains and cause this problem.

     A more stable value is AppDomain.CurrentDomain.BaseDirectory.  This value is AppDomain specific, immutable, and was already sufficient to load this particular assembly.
 (changeset 1409768)
上级 9c1de4ac
......@@ -66,7 +66,7 @@ private void CreateAssemblyManager(IEnumerable<ModuleData> compilationDependenci
RuntimeAssemblyManager manager;
try
{
appDomain = AppDomain.CreateDomain("HostedRuntimeEnvironment", null, Environment.CurrentDirectory, null, false);
appDomain = AppDomain.CreateDomain("HostedRuntimeEnvironment", null, AppDomain.CurrentDomain.BaseDirectory, null, false);
manager = (RuntimeAssemblyManager)appDomain.CreateInstanceAndUnwrap(thisAssembly.FullName, appDomainProxyType.FullName);
}
catch
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册