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

Recently, I was developing web API in .NET 8 and found the error saying the below statement with status code 500.

Only the invariant culture is supported in globalization-invariant mode. 

Below is the error screenshot.

Reason for the Error –

The error message indicates that you attempted to use a culture identifier that is not the invariant culture. When enabling the invariant mode, all cultures behave like the invariant culture. Culture names (English, native display, ISO, language names) will return invariant names. For instance, when requesting a culture native name, you will get “Invariant Language (Invariant Country)”.

This mode restricts the use of specific cultures to only the invariant culture.

Possible Solution –

If you’re using .NET Core 8, check your project configuration. Look for the tag InvariantGlobalization, and change the value to false to disable invariant globalization.

You may do this using the below options. Right-click on Project in Visual Studio and select Edit Project file. Search for InvariantGlobalization and change the value to false.

Now check the API, it should work.

Leave a Comment