New to Telerik Reporting? Download free 30-day trial

Parameter 'Culture' Is an Invalid Culture Identifier

Environment

Product Progress® Telerik® Reporting
Project Type ASP.NET Core Web API
Target Framework .NET 6+

Description

I have created a new ASP.NET Core project using the Visual Studio project templates targetting .NET 8+ and upon integrating the HTML5 Report Viewer/Designer on one of the pages of the web application, the below error is displayed on the page instead of the specified report.

Steps to Reproduce

Run the ASP.NET Core application in .NET Core Globalization Invariant Mode. Projects created with Visual Studio's ASP.NET Core Web API that target .NET 6+ use this setting by default.

The Invariant Mode can be turned on in multiple ways with the most common being the project .csproj file:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <InvariantGlobalization>true</InvariantGlobalization>
    </PropertyGroup>
</Project>

Error Message

  • For product version <= 17.0.23.315:

    Unable to get report parameters. An error has occurred. The type initializer for 'Telerik.Reporting.Interfaces.LocalizationContext' threw an exception.

  • For newer versions:

    Unable to get report parameters. An error has occurred. Only the invariant culture is supported in the globalization-invariant mode. See https://aka.ms/GlobalizationInvariantMode for more information. (Parameter 'culture') 1033 (0x0409) is an invalid culture identifier.

Cause

The InvariantGlobalization property causes the runtime to throw a CultureNotFound exception when a new instance of CultureInfo is created. In the LocalizationContext class, we create a default CultureInfo instance, using the "en" culture as default which causes the exception.

Suggested Workarounds

Workaround 1

Disable the Invariant globalization setting from the project file:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <InvariantGlobalization>false</InvariantGlobalization>
    </PropertyGroup>
</Project>

Workaround 2

Disable the Invariant globalization setting from the runtimeconfig.json file:

{
    "runtimeOptions": {
        "configProperties": {
            "System.Globalization.Invariant": false
        }
    }
}

Workaround 3

Use the DOTNET_SYSTEM_GLOBALIZATION_INVARIANT environment variable whose values can be:

  • 0 - Access to cultural data
  • 1 - Run in invariant mode

See Also

In this article