diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs index a644947b73463e..e18c1ffdda8ab6 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/TypeMapLazyDictionary.cs @@ -192,11 +192,11 @@ private static unsafe CallbackContext CreateMaps( RuntimeAssembly? startingAssembly; if (AppContext.GetData("System.Runtime.InteropServices.TypeMappingEntryAssembly") is string entryAssemblyName) { - startingAssembly = Assembly.Load(entryAssemblyName) as RuntimeAssembly; + startingAssembly = (RuntimeAssembly?)Assembly.Load(entryAssemblyName); } else { - startingAssembly = Assembly.GetEntryAssembly() as RuntimeAssembly; + startingAssembly = (RuntimeAssembly?)Assembly.GetEntryAssembly(); } if (startingAssembly is null)