check for Null returned from Assembly.GetEntryAssembly (#40598)
authorManish Godse <61718172+mangod9@users.noreply.github.com>
Mon, 10 Aug 2020 03:00:59 +0000 (20:00 -0700)
committerGitHub <noreply@github.com>
Mon, 10 Aug 2020 03:00:59 +0000 (20:00 -0700)
Fixes 40588

src/libraries/System.Private.Xml/src/System/Xml/Serialization/Compilation.cs

index fe7d84f..67ce05a 100644 (file)
@@ -163,7 +163,7 @@ namespace System.Xml.Serialization
                         serializerPath = Path.Combine(Path.GetDirectoryName(type.Assembly.Location), serializerName + ".dll");
                     }
 
-                    if ((string.IsNullOrEmpty(serializerPath) || !File.Exists(serializerPath)) && !string.IsNullOrEmpty(Assembly.GetEntryAssembly().Location))
+                    if ((string.IsNullOrEmpty(serializerPath) || !File.Exists(serializerPath)) && !string.IsNullOrEmpty(Assembly.GetEntryAssembly()?.Location))
                     {
                         serializerPath = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), serializerName + ".dll");
                     }