88using System . Collections . Concurrent ;
99using System . Collections . Generic ;
1010using System . Globalization ;
11+ using System . Linq ;
1112using System . Runtime . InteropServices ;
1213using System . Reflection ;
1314using System . Reflection . Metadata ;
@@ -91,6 +92,9 @@ private PowerShellAssemblyLoadContext(string basePaths, bool useResolvingHandler
9192
9293 trace = System . Environment . GetEnvironmentVariable ( "ALC_TRACE" ) == "1" ;
9394
95+ if ( trace )
96+ Console . WriteLine ( " == APPBASE == {0}" , basePaths ) ;
97+
9498 this . basePaths = basePaths . Split ( new char [ ] { ';' } , StringSplitOptions . RemoveEmptyEntries ) ;
9599 for ( int i = 0 ; i < this . basePaths . Length ; i ++ )
96100 {
@@ -195,12 +199,17 @@ protected override Assembly Load(AssemblyName assemblyName)
195199
196200 if ( trace )
197201 System . Console . WriteLine ( "== LC1 == Requesting: {0}" , assemblyName . FullName ) ;
202+
198203 if ( filterSet == null )
199204 {
200- filterSet = new HashSet < string > ( coreClrTypeCatalog . Values ) ;
205+ // We exclude the assemblies included in the type catalog as there appears to be a
206+ // bug in .NET with method resolution with system libraries are loaded by our
207+ // context and not the default. We use the short name because some packages have
208+ // inconsistent verions between reference and runtime assemblies.
209+ filterSet = new HashSet < string > ( from x in coreClrTypeCatalog . Values select x . Substring ( 0 , x . IndexOf ( "," ) ) ) ;
201210 }
202-
203- if ( filterSet . Contains ( assemblyName . FullName ) )
211+
212+ if ( filterSet . Contains ( assemblyName . Name ) )
204213 {
205214 if ( trace )
206215 System . Console . WriteLine ( " ++ Return null from Load override" ) ;
@@ -463,7 +472,7 @@ internal IEnumerable<string> GetAvailableDotNetTypes()
463472 }
464473
465474 /// <summary>
466- /// Set the profile optimization root on the approprite load context
475+ /// Set the profile optimization root on the appropriate load context
467476 /// </summary>
468477 internal void SetProfileOptimizationRootImpl ( string directoryPath )
469478 {
@@ -472,7 +481,7 @@ internal void SetProfileOptimizationRootImpl(string directoryPath)
472481 }
473482
474483 /// <summary>
475- /// Start the profile optimization on the approprite load context
484+ /// Start the profile optimization on the appropriate load context
476485 /// </summary>
477486 internal void StartProfileOptimizationImpl ( string profile )
478487 {
0 commit comments