dotnet/runtime · error · Error
Locale info for locale=
Error message
Locale info for locale=${localeName} exceeds length of ${dstMaxLength}. What it means
Thrown by SystemJS_GetLocaleInfo in globalization-locale.ts when the resolved locale info string (LanguageName##RegionName) is longer than dstMaxLength, the managed-side destination buffer capacity. The check protects against buffer overflow when marshalling the result back to managed memory. Caught locally, reported to managed code via dstLength=-1 and the error string.
Solutions
- Increase the destination buffer size (dstMaxLength) on the managed side that calls the interop.
- Update the .NET runtime to a version whose managed caller allocates a correctly sized buffer.
- If using a custom interop wrapper, size the buffer from the locale string length plus headroom.
Example fix
// before: fixed 64-char buffer
var buf = new string('\0', 64);
// after: size generously for display names
var buf = new string('\0', 512); Defensive patterns
Strategy: validation
Validate before calling
// managed side: allocate a buffer large enough for localized names
const int MaxLocaleInfoLength = 512;
var dst = new string('\0', MaxLocaleInfoLength); Try / catch
// forwarded via dstLength=-1; caller checks that and resizes/retries
if (dstLength == -1) { /* increase buffer, retry once */ } Prevention
- Size locale-info buffers generously (>= 256 chars).
- Keep the runtime and its managed caller from the same build so buffer sizing stays consistent.
- Treat dstLength=-1 as a recoverable signal and fall back to the raw locale code.
When it happens
Trigger: Managed code allocated a destination buffer too small for the localized display names; very long language/region display names (some locales produce multi-word names); a downstream change that increased display-name length without resizing the native buffer.
Common situations: A runtime/SDK update that changed ICU display-name formatting so results grew; a custom marshaler with a hardcoded buffer size; locales with long names (e.g. some zh-Hant names) against a too-small buffer.
Related errors
- Locale info for locale=
- Locale info for locale=
- Locale info for locale=
- Locale or culture name is null or empty. localeName=
- Locale or culture name is null or empty. localeName=
AI-assisted analysis of dotnet/runtime@60108ba66e (2026-08-10).
Data as JSON: /api/errors/df82cb13a72ce7ae.
Report an issue: GitHub.
Appendix: 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 60108ba66e)