Remove PKT for mscorlib to allow PathAssemblyResolver to return most recent assembly version

上级 05ce539a
......@@ -98,6 +98,9 @@
<Compile Include="$(WpfSharedDir)\System\Windows\Markup\ReflectionHelper.cs">
<Link>Shared\System\Windows\Markup\ReflectionHelper.cs</Link>
</Compile>
<Compile Include="$(WpfSharedDir)\System\Windows\Markup\RetargetablePathAssemblyResolver.cs">
<Link>Shared\System\Windows\Markup\RetargetablePathAssemblyResolver.cs</Link>
</Compile>
<Compile Include="$(WpfSharedDir)\MS\Internal\Xaml\Parser\SpecialBracketCharacters.cs">
<Link>Shared\MS\Internal\Xaml\Parser\SpecialBracketCharacters.cs</Link>
</Compile>
......
......@@ -62,7 +62,7 @@ internal static void Initialize(IEnumerable<string> assemblyPaths)
// System.Reflection.MetadataLoadContext Assembly cache
_cachedMetadataLoadContextAssemblies = new Dictionary<string, Assembly>(StringComparer.OrdinalIgnoreCase);
_cachedMetadataLoadContextAssembliesByNameNoExtension = new Dictionary<string, Assembly>(StringComparer.OrdinalIgnoreCase);
_metadataLoadContext = new MetadataLoadContext(new PathAssemblyResolver(assemblyPaths), MscorlibReflectionAssemblyName);
_metadataLoadContext = new MetadataLoadContext(new RetargetablePathAssemblyResolver(assemblyPaths), MscorlibReflectionAssemblyName);
_localAssemblyName = string.Empty;
}
......
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.IO;
using System.Reflection;
namespace MS.Internal.Markup
{
public class RetargetablePathAssemblyResolver : MetadataAssemblyResolver
{
private PathAssemblyResolver _pathAssemblyResolver;
public RetargetablePathAssemblyResolver(IEnumerable<string> assemblyPaths)
{
_pathAssemblyResolver = new PathAssemblyResolver(assemblyPaths);
}
public override Assembly Resolve(MetadataLoadContext context, AssemblyName assemblyName)
{
// PathAssemblyResolver will resolve the target assembly to the highest
// version of the target assembly available in the 'assemblyPaths' assembly
// list, only if the public key token for the target assembly is not set.
// Remove the public key token from 'mscorlib' to allow PathAssemblyResolver
// to resolve the most recent version of 'mscorlib'.
if (assemblyName.Name.Equals(ReflectionHelper.MscorlibReflectionAssemblyName))
{
assemblyName.SetPublicKeyToken(null);
}
return _pathAssemblyResolver.Resolve(context, assemblyName);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册