diff options
author | Steve MacLean <stmaclea@microsoft.com> | 2019-04-11 23:48:59 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-11 23:48:59 -0400 |
commit | daa688d788fa470133ef21b0b51f18e9d91d1228 (patch) | |
tree | 84ac3b6e3a0cc42df42bc8b2eaf86e7f51759643 | |
parent | 2a46c2580580b31d7fa18ea381d2aa838f31d025 (diff) | |
download | coreclr-daa688d788fa470133ef21b0b51f18e9d91d1228.tar.gz coreclr-daa688d788fa470133ef21b0b51f18e9d91d1228.tar.bz2 coreclr-daa688d788fa470133ef21b0b51f18e9d91d1228.zip |
Fix Assembly.LoadFromPartialName(string) (#23912)
Assembly.LoadFromPartialName(string) should not throw FileNotFoundException, but
should rather return null.
ArgumentException should use nameof(partialName)
Fixes #19817
-rw-r--r-- | src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs b/src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs index 3db428ed79..1e9699f62f 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 |