Cannot load Japanese Satellite Assembly
My product targets .NETStandard 2.0 and .NET Framework 4.5.2.
A satellite-assembly test running on an English-US Windows laptop changes the thread.CurrentUICulture and thread.CurrentCulture to ja-JP and throws an exception. This test cases succeeds in .NET Framework but fails in .NET Core 2.0. The exception is
The active test run was aborted. Reason: me fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks, IntPtr ptrLoadContextBinder) at System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(String name, CultureInfo culture, Version version, Boolean throwOnFileNotFound, StackCrawlMark& stackMark) at System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly(CultureInfo lookForCulture, StackCrawlMark& stackMark) at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark) at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark) at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents) at System.Resources.ResourceManager.GetObject(String name, CultureInfo culture, Boolean wrapUnmanagedMemStream)
This issue is similar to dotnet/runtime#8503 .
I debugged it to
internal RuntimeAssembly InternalGetSatelliteAssembly(String name,
CultureInfo culture,
Version version,
bool throwOnFileNotFound,
ref StackCrawlMark stackMark)
{
AssemblyName an = new AssemblyName();
an.SetPublicKey(GetPublicKey());
an.Flags = GetFlags() | AssemblyNameFlags.PublicKey;
if (version == null)
an.Version = GetVersion();
else
an.Version = version;
an.CultureInfo = culture;
an.Name = name;
RuntimeAssembly retAssembly = nLoad(an, null, null, this, ref stackMark,
IntPtr.Zero,
throwOnFileNotFound, false);
if (retAssembly == this || (retAssembly == null && throwOnFileNotFound))
{
throw new FileNotFoundException(String.Format(culture, SR.IO_FileNotFound_FileName, an.Name));
}
return retAssembly;
}
The "name", "culture" and version are correct. The satellite assembly is built and available in "ja" directory.
How can I identify the root cause?
NUnit or Microsoft.NET.Test.Sdk does not display entire message. I wrote a console app to capture the message
Assert Failure
Expression: [Recursive resource lookup bug]
Description: Infinite recursion during resource lookup within System.Private.CoreLib. This may be a bug in System.Private.CoreLib, or potentially in certain extensibility points such as assembly resolve events or CultureInfo names. Resource name: ArgumentNull_Generic
Stack Trace:
at System.SR.InternalGetResourceString(String key)
at System.SR.GetResourceString(String resourceKey, String defaultString)
at System.ArgumentNullException..ctor(String paramName)
at System.Runtime.Loader.AssemblyLoadContext.GetLoadContext(Assembly assembly)
at System.Reflection.Assembly.LoadFromResolveHandler(Object sender, ResolveEventArgs args)
at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
dotnet --info
.NET Command Line Tools (2.0.2)
Product Information:
Version: 2.0.2
Commit SHA-1 hash: a04b4bf512
Runtime Environment:
OS Name: Windows
OS Version: 10.0.15063
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.0.2\
Microsoft .NET Core Shared Framework Host
Version : 2.0.0
Build : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d
Duplicate of dotnet/runtime#8956