Skip to content

[8.0.100-preview.6.23310.1] System.Globalization.CultureNotFoundException: "Culture is not supported." #87394

Closed

Description

@Junjun-zhao

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

  1. Create a default Console project.
  2. Write the following code in Program.cs.
   using System.Globalization;
   Console.WriteLine(new CultureInfo("zh_CN"));
  1. Build the project.
  2. 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"
      }
    ]
  1. 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:

  1. Windows10 21h2 x64 + dotnet-sdk-8.0.100-preview.6.23310.1: Fail
  2. Windows10 21h2 x64 + dotnet-sdk-8.0.100-preview.6.23305.4: Pass
  3. 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

Activity

  1. ghost added
    untriaged
    on Jun 12, 2023
  2. ghost added
    needs-area-label
    on Jun 12, 2023
  3. added this to the 8.0.0 milestone on Jun 12, 2023
  4. ghost removed
    untriaged
    on Jun 12, 2023
  5. removed
    needs-area-label
    on Jun 12, 2023
  6. self-assigned this
    on Jun 12, 2023
  7. tarekgh commented on Jun 13, 2023

    @tarekgh
    Member

    This should be fixed now by #87411.

    @Junjun-zhao thanks for reporting the issue.

  8. Junjun-zhao commented on Jun 19, 2023

    @Junjun-zhao
    MemberAuthor

    Verified this issue and it has been fixed on dotnet-sdk-8.0.100-preview.6.23316.32. Thank you.

  9. tarekgh commented on Jun 19, 2023

    @tarekgh
    Member
  10. ghost locked as resolved and limited conversation to collaborators on Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions