Filter runtime assemblies out of custom context

This commit is contained in:
Andrew Schwartzmeyer
2016-06-28 19:19:55 -07:00
parent 5a29df50f1
commit 2360d1ef46
2 changed files with 14 additions and 7 deletions
@@ -8,6 +8,7 @@ using System.IO;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices;
using System.Reflection;
using System.Reflection.Metadata;
@@ -91,6 +92,9 @@ namespace System.Management.Automation
trace = System.Environment.GetEnvironmentVariable("ALC_TRACE") == "1";
if (trace)
Console.WriteLine(" == APPBASE == {0}", basePaths);
this.basePaths = basePaths.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < this.basePaths.Length; i++)
{
@@ -195,12 +199,17 @@ namespace System.Management.Automation
if (trace)
System.Console.WriteLine("== LC1 == Requesting: {0}", assemblyName.FullName);
if (filterSet == null)
{
filterSet = new HashSet<string>(coreClrTypeCatalog.Values);
// We exclude the assemblies included in the type catalog as there appears to be a
// bug in .NET with method resolution with system libraries are loaded by our
// context and not the default. We use the short name because some packages have
// inconsistent verions between reference and runtime assemblies.
filterSet = new HashSet<string>(from x in coreClrTypeCatalog.Values select x.Substring(0, x.IndexOf(",")));
}
if (filterSet.Contains(assemblyName.FullName))
if (filterSet.Contains(assemblyName.Name))
{
if (trace)
System.Console.WriteLine(" ++ Return null from Load override");
@@ -463,7 +472,7 @@ namespace System.Management.Automation
}
/// <summary>
/// Set the profile optimization root on the approprite load context
/// Set the profile optimization root on the appropriate load context
/// </summary>
internal void SetProfileOptimizationRootImpl(string directoryPath)
{
@@ -472,7 +481,7 @@ namespace System.Management.Automation
}
/// <summary>
/// Start the profile optimization on the approprite load context
/// Start the profile optimization on the appropriate load context
/// </summary>
internal void StartProfileOptimizationImpl(string profile)
{
-2
View File
@@ -24,8 +24,6 @@ namespace Microsoft.PowerShell
#if CORECLR
// Open PowerShell has to set the ALC here, since we don't own the native host
string appBase = System.IO.Path.GetDirectoryName(typeof(ManagedPSEntry).GetTypeInfo().Assembly.Location);
Console.WriteLine(" == APPBASE == {0}", appBase);
//Console.Read();
return (int)PowerShellAssemblyLoadContextInitializer.
InitializeAndCallEntryMethod(
appBase,