diff options
-rw-r--r-- | src/mscorlib/src/System/Reflection/Assembly.CoreCLR.cs | 6 | ||||
-rw-r--r-- | src/vm/appdomain.cpp | 24 |
2 files changed, 21 insertions, 9 deletions
diff --git a/src/mscorlib/src/System/Reflection/Assembly.CoreCLR.cs b/src/mscorlib/src/System/Reflection/Assembly.CoreCLR.cs index bbbd80b58b..d437e05e31 100644 --- a/src/mscorlib/src/System/Reflection/Assembly.CoreCLR.cs +++ b/src/mscorlib/src/System/Reflection/Assembly.CoreCLR.cs @@ -22,7 +22,11 @@ namespace System.Reflection private static Assembly LoadFromResolveHandler(object sender, ResolveEventArgs args) { Assembly requestingAssembly = args.RequestingAssembly; - + if (requestingAssembly == null) + { + return null; + } + // Requesting assembly for LoadFrom is always loaded in defaultContext - proceed only if that // is the case. if (AssemblyLoadContext.Default != AssemblyLoadContext.GetLoadContext(requestingAssembly)) diff --git a/src/vm/appdomain.cpp b/src/vm/appdomain.cpp index 946009ac06..a4499395bf 100644 --- a/src/vm/appdomain.cpp +++ b/src/vm/appdomain.cpp @@ -7078,18 +7078,26 @@ EndTry2:; } else if (!fIsWellKnown) { - // Trigger the resolve event also for non-throw situation. - // However, this code path will behave as if the resolve handler has thrown, - // that is, not trigger an MDA. _ASSERTE(fThrowOnFileNotFound == FALSE); - AssemblySpec NewSpec(this); - AssemblySpec *pFailedSpec = NULL; + // Don't trigger the resolve event for the CoreLib satellite assembly. A misbehaving resolve event may + // return an assembly that does not match, and this can cause recursive resource lookups during error + // reporting. The CoreLib satellite assembly is loaded from relative locations based on the culture, see + // AssemblySpec::Bind(). + if (!pSpec->IsMscorlibSatellite()) + { + // Trigger the resolve event also for non-throw situation. + // However, this code path will behave as if the resolve handler has thrown, + // that is, not trigger an MDA. + + AssemblySpec NewSpec(this); + AssemblySpec *pFailedSpec = NULL; - fForceReThrow = TRUE; // Managed resolve event handler can throw + fForceReThrow = TRUE; // Managed resolve event handler can throw - // Purposly ignore return value - PostBindResolveAssembly(pSpec, &NewSpec, hrBindResult, &pFailedSpec); + // Purposly ignore return value + PostBindResolveAssembly(pSpec, &NewSpec, hrBindResult, &pFailedSpec); + } } } } |