提交 f364577a 编写于 作者: T Tanner Gooding

Adding an assembly resolver which returns the already loaded assembly.

上级 950fe6e7
......@@ -28,6 +28,24 @@ static VisualStudioInstanceFactory()
{
throw new PlatformNotSupportedException("The Visual Studio Integration Test Framework is only supported on Visual Studio 15.0 and later.");
}
// This looks like it is pointless (since we are returning an assembly that is already loaded) but it is actually required.
// The BinaryFormatter, when invoking 'HandleReturnMessage', will end up attempting to call 'BinaryAssemblyInfo.GetAssembly()',
// which will itself attempt to call 'Assembly.Load()' using the full name of the assembly for the type that is being deserialized.
// Depending on the manner in which the assembly was originally loaded, this may end up actually trying to load the assembly a second
// time and it can fail if the standard assembly resolution logic fails. This ensures that we 'succeed' this secondary load by returning
// the assembly that is already loaded.
AppDomain.CurrentDomain.AssemblyResolve += (sender, eventArgs) => {
Debug.WriteLine($"'{eventArgs.RequestingAssembly}' is attempting to resolve '{eventArgs.Name}'");
var resolvedAssembly = AppDomain.CurrentDomain.GetAssemblies().Where((assembly) => assembly.FullName.Equals(eventArgs.Name)).SingleOrDefault();
if (resolvedAssembly != null)
{
Debug.WriteLine("The assembly was already loaded!");
}
return resolvedAssembly;
};
}
/// <summary>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册