What is the status and design regarding localization of system exception messages in .NET Core (.NET 5)? Are they supposed to be localized? Is there something like "language packs" that can be installed for the .NET Core runtime?
Localization/translation of system exception messages it not working in .NET 5.
I have the following code:
static void Main()
{
var culture = new CultureInfo("de-DE");
CultureInfo.CurrentUICulture = culture;
var nre = new NullReferenceException();
Console.WriteLine(nre);
}
This always produces English output (at least when running on Windows with English as the primary language) when running on .NET 5, no matter what I set the CurrentUICulture (or CurrentCulture) to.
System.NullReferenceException: Object reference not set to an instance of an object.
This used to be different on .NET Framework, at least when the target language pack is installed. Here's what I get when I change TargetFramework from net5.0 to e. g. net462 in the .csproj file:
System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
I had a look into the source code of the NullReferenceException class and it seems to be prepared for localization. At least it retrieves the error message from some StringResources. But up to now there are only English resources available. Or did I miss something?