Remove PKT for mscorlib to allow PathAssemblyResolver to return most recent assembly version
This commit is contained in:
Родитель
05ce539a03
Коммит
c5cfbbfd3a
|
@ -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 @@ namespace System.Xaml
|
|||
// 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче