From 27e625f0108915fb514e20c870072fbef2d6291c Mon Sep 17 00:00:00 2001 From: Gaurav Khanna Date: Fri, 16 Jun 2017 17:26:11 -0700 Subject: [PATCH] LoadFromResolve event handler should return null incase of any load error (#12329) --- src/mscorlib/src/System/Reflection/Assembly.CoreCLR.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/mscorlib/src/System/Reflection/Assembly.CoreCLR.cs b/src/mscorlib/src/System/Reflection/Assembly.CoreCLR.cs index 68a4aa0..bbbd80b 100644 --- a/src/mscorlib/src/System/Reflection/Assembly.CoreCLR.cs +++ b/src/mscorlib/src/System/Reflection/Assembly.CoreCLR.cs @@ -51,7 +51,19 @@ namespace System.Reflection string requestedAssemblyPath = Path.Combine(Path.GetDirectoryName(requestorPath), requestedAssemblyName.Name+".dll"); // Load the dependency via LoadFrom so that it goes through the same path of being in the LoadFrom list. - return Assembly.LoadFrom(requestedAssemblyPath); + Assembly resolvedAssembly = null; + + try + { + resolvedAssembly = Assembly.LoadFrom(requestedAssemblyPath); + } + catch(FileNotFoundException) + { + // Catch FileNotFoundException when attempting to resolve assemblies via this handler to account for missing assemblies. + resolvedAssembly = null; + } + + return resolvedAssembly; } public static Assembly LoadFrom(String assemblyFile) -- 2.7.4