diff --git a/src/libraries/System.Reflection/tests/AssemblyNameTests.cs b/src/libraries/System.Reflection/tests/AssemblyNameTests.cs index 951bad32cdfb00..1960027c1ff132 100644 --- a/src/libraries/System.Reflection/tests/AssemblyNameTests.cs +++ b/src/libraries/System.Reflection/tests/AssemblyNameTests.cs @@ -295,10 +295,11 @@ public static void Clone() [Fact] public static void GetAssemblyName() { - if (!PlatformDetection.IsNativeAot) + Assembly a = typeof(AssemblyNameTests).Assembly; + string assemblyLocation = AssemblyPathHelper.GetAssemblyLocation(a); + if (!string.IsNullOrEmpty(assemblyLocation)) { - Assembly a = typeof(AssemblyNameTests).Assembly; - Assert.Equal(new AssemblyName(a.FullName).ToString(), AssemblyName.GetAssemblyName(AssemblyPathHelper.GetAssemblyLocation(a)).ToString()); + Assert.Equal(new AssemblyName(a.FullName).ToString(), AssemblyName.GetAssemblyName(assemblyLocation).ToString()); } }