-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
Description
When test the 3rd party App with latest .NET 8.0 SDK build, it prompts the System.Globalization.CultureNotFoundException that Culture is not supported.
Application Name: CleanArchitecture2, PicView
OS: Windows 10 21H2
CPU: X64
.NET Build Number: dotnet-sdk-8.0.100-preview.6.23310.1
App or App Source Checking at: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1834006
Repro steps:
The machine only has dotnet-sdk-8.0.100-preview.6.23310.1 installed and DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX set as 2.
1.Restore database in “\CleanArchitecture2\database”.
2.Launch BlazorHero.CleanArchitecture.Server.exe in "\CleanArchitecture2".
Expected Result:
launch successfully.
Actual Result:
launch failed with following error:
Unhandled exception. System.Globalization.CultureNotFoundException: Culture is not supported. (Parameter 'name')
km_KH is an invalid culture identifier.
at System.Globalization.CultureInfo..ctor(String name, Boolean useUserOverride)
at System.Globalization.CultureInfo..ctor(String name)
at BlazorHero.CleanArchitecture.Server.Extensions.ApplicationBuilderExtensions.<>c.<UseRequestLocalizationByCulture>b__4_0(LanguageCode l) in D:\New folder\CleanArchitecture\src\Server\Extensions\ApplicationBuilderExtensions.cs:line 67
at System.Linq.Enumerable.SelectArrayIterator`2.Fill(ReadOnlySpan`1 source, Span`1 destination, Func`2 func)
at System.Linq.Enumerable.SelectArrayIterator`2.ToArray()
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at BlazorHero.CleanArchitecture.Server.Extensions.ApplicationBuilderExtensions.UseRequestLocalizationByCulture(IApplicationBuilder app) in D:\New folder\CleanArchitecture\src\Server\Extensions\ApplicationBuilderExtensions.cs:line 67
at BlazorHero.CleanArchitecture.Server.Startup.Configure(IApplicationBuilder app, IWebHostEnvironment env, IStringLocalizer`1 localizer) in D:\New folder\CleanArchitecture\src\Server\Startup.cs:line 83
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
at Microsoft.Extensions.DependencyInjection.AutoRegisterMiddleware.<>c__DisplayClass4_0.<Configure>b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.Internal.Host.StartAndTryToExecuteAsync(IHostedService service, CancellationToken combinedCancellationToken)
at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at BlazorHero.CleanArchitecture.Server.Program.Main(String[] args) in D:\New folder\CleanArchitecture\src\Server\Program.cs:line 42
at BlazorHero.CleanArchitecture.Server.Program.<Main>(String[] args)
Reproduction Steps
Minimal Repro steps (Demo attached):
CultureDemo.zip
- Create a default Console project.
- Write the following code in Program.cs.
using System.Globalization;
Console.WriteLine(new CultureInfo("zh_CN"));
- Build the project.
- Change the runtime.config file to let the app run against with dotnet-sdk-8.0.100-preview.6.23310.1
"frameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "8.0.0-preview.6.23307.4"
},
{
"name": "Microsoft.AspNetCore.App",
"version": "8.0.0-preview.6.23307.4"
}
]
- Launch the demo app.
Expected behavior
App will launch success.
Actual behavior
Launch failed with exception "System.Globalization.CultureNotFoundException: 'Culture is not supported.'".
Regression?
Yes
Verify Scenarios:
- Windows10 21h2 x64 + dotnet-sdk-8.0.100-preview.6.23310.1: Fail
- Windows10 21h2 x64 + dotnet-sdk-8.0.100-preview.6.23305.4: Pass
- Windows10 21h2 x64 + dotnet-sdk-6.0.410: Pass
Known Workarounds
No response
Configuration
No response
Other information
Findings
We found that the locale format like "zh_CN" and "km_KH" don't work with the latest build dotnet-sdk-8.0.100-preview.6.23310.1, but it worked with the build dotnet-sdk-8.0.100-preview.6.23305.4 or earlier build. If we change "zh_CN" to "zh-CN" or change "km_KH" to "km-KH", it works. This may be a matter of symbols. This is the related commit we found:
Account for PredefinedCulturesOnly in CultureInfo LCID .ctor by OwnageIsMagic · Pull Request #87002 · dotnet/runtime · GitHub
Also, we tried with .NET Framework 4.8.1, both of "zh_CN"/"km_KH" and "zh-CN"/"km-KH" work fine.
@dotnet-actwx-bot @dotnet/compat