dotnet/runtime · error · Error

Locale info for locale=${localeName} exceeds length of ${dst

Error message

Locale info for locale=${localeName} exceeds length of ${dstMaxLength}.

What it means

Thrown by SystemJS_GetLocaleInfo when the resolved locale-info string (LanguageName##RegionName) is longer than the destination buffer (dstMaxLength) allocated by the .NET caller. The runtime refuses to truncate and instead surfaces a contract violation between the managed buffer size and the JS-produced string.

Source

Thrown at src/mono/browser/runtime/globalization-locale.ts:85

                        return VoidPtrNull;
                    }
                    throw error;
                }
            } else {
                throw error;
            }
        }
        const localeInfo = {
            LanguageName: languageName,
            RegionName: regionName,
        };
        const result = Object.values(localeInfo).join(OUTER_SEPARATOR);

        if (!result)
            throw new Error(`Locale info for locale=${localeName} is null or empty.`);

        if (result.length > dstMaxLength)
            throw new Error(`Locale info for locale=${localeName} exceeds length of ${dstMaxLength}.`);

        stringToUTF16(dst, dst + 2 * result.length, result);
        setI32(dstLength, result.length);
        return VoidPtrNull;
    } catch (ex: any) {
        setI32(dstLength, -1);
        return stringToUTF16Ptr(ex.toString());
    }
}

View on GitHub (pinned to 290d5ab72c)

Solutions

  1. Update the .NET runtime WASM packages and the Microsoft.NET.Sdk.Web SDK to matching versions so the buffer sizing contract is consistent.
  2. Use a culture whose display names are shorter, or a more standard culture tag, as a workaround during development.
  3. If you maintain a custom host, ensure the managed buffer allocated for locale info is large enough (at least several hundred UTF-16 code units) for any culture you support.
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Produced when the .NET-side caller passes a destination buffer whose dstMaxLength is smaller than the combined length of the resolved LanguageName and RegionName display strings, e.g. a culture whose localized names are very long (some languages produce long display names) being written into a short buffer.

Common situations: Hitting this typically means an internal version mismatch between the JS runtime and the managed marshaler that sizes the buffer, or a locale whose localized display-name forms are unexpectedly long. End-user code almost never triggers this directly; it surfaces during culture initialization.

Related errors


AI-assisted analysis of dotnet/runtime@290d5ab72c (2026-08-06). Data as JSON: /api/errors/df82cb13a72ce7ae. Report an issue: GitHub.