CultureNotFoundException: Only the invariant culture is supported in globalization-invariant mode

Hello,

I'm trying to make my app culture invariant by adding the InvariantGlobalization = true property in the project file

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
	<GenerateDocumentationFile>true</GenerateDocumentationFile>
	<NoWarn>$(NoWarn);1591</NoWarn>
	<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
	<PlatformTarget>x64</PlatformTarget>
	<InvariantGlobalization>true</InvariantGlobalization>
  </PropertyGroup>

When I did, I start getting these errors on app-start, and can't figure out where to fix this

[07:21:15 ERR] {SystemTotalCpuProvider} Error instantiating 'Processor' performance counter
System.Globalization.CultureNotFoundException: Only the invariant culture is supported in globalization-invariant mode. See https://aka.ms/GlobalizationInvariantMode for more information. (Parameter 'culture')
9 (0x0009) is an invalid culture identifier.
   at System.Globalization.CultureData.GetCultureData(Int32 culture, Boolean bUseUserOverride)
   at System.Globalization.CultureInfo..ctor(Int32 culture, Boolean useUserOverride)
   at System.Diagnostics.PerformanceCounterLib.CounterExists(String machine, String category, String counter)
   at System.Diagnostics.PerformanceCounter.InitializeImpl()
   at System.Diagnostics.PerformanceCounter..ctor(String categoryName, String counterName, String instanceName, Boolean readOnly)
   at Elastic.Apm.Metrics.MetricsProvider.SystemTotalCpuProvider.GetSamples()
[07:21:15 WRN] {SystemTotalCpuProvider} System metrics won't be collected
[07:21:15 WRN] {MetricsCollector} Failed reading total system CPU time 1 times: no valid samples

Any ideas?

Elasticsearch version:
v8.5.2

APM Server version:
v8.5.2

APM Agent language and version:
Elastic.Apm.NetCoreAll, v1.19.0

1 Like

Hi @jimmie,

thanks for bringing this to our attention.

Would you mind creating a GitHub issue for that?
That way can consider the problem in our planning and triaging sessions and you can better follow the progress.

Thanks,
Wolfgang

Ok sure,

done; [BUG] CultureNotFoundException: Only the invariant culture is supported in globalization-invariant mode · Issue #1985 · elastic/apm-agent-dotnet · GitHub

thank you

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.