From: Steve MacLean Date: Fri, 12 Apr 2019 03:48:59 +0000 (-0400) Subject: Fix Assembly.LoadFromPartialName(string) (#23912) X-Git-Tag: accepted/tizen/unified/20190813.215958~46^2~114 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=daa688d788fa470133ef21b0b51f18e9d91d1228;p=platform%2Fupstream%2Fcoreclr.git Fix Assembly.LoadFromPartialName(string) (#23912) Assembly.LoadFromPartialName(string) should not throw FileNotFoundException, but should rather return null. ArgumentException should use nameof(partialName) Fixes #19817 --- diff --git a/src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs b/src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs index 3db428e..1e9699f 100644 --- a/src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs +++ b/src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs @@ -205,7 +205,17 @@ namespace System.Reflection if (partialName == null) throw new ArgumentNullException(nameof(partialName)); - return Load(partialName); + if ((partialName.Length == 0) || (partialName[0] == '\0')) + throw new ArgumentException(SR.Format_StringZeroLength, nameof(partialName)); + + try + { + return Load(partialName); + } + catch (FileNotFoundException) + { + return null; + } } // Loads the assembly with a COFF based IMAGE containing