tui-cs/Terminal.Gui · error · JsonException
Error Applying Configuration Change ({PropertyInfo?.Name}):
Error message
Error Applying Configuration Change ({PropertyInfo?.Name}): {ae.Message} What it means
Thrown by ConfigProperty.Apply when SetValue (or DeepCloner.DeepClone beforehand) raises an ArgumentException directly (not wrapped in TargetInvocationException). Typically means the value's type does not match the property's declared type, or an invalid argument was passed to the setter. The property name is included.
Source
Thrown at Terminal.Gui/Configuration/ConfigProperty.cs:103
PropertyInfo.SetValue (null, val);
}
}
catch (TargetInvocationException tie)
{
if (tie.InnerException is { })
{
throw new JsonException (
$"Error Applying Configuration Change: {tie.InnerException.Message}",
tie.InnerException
);
}
throw new JsonException ($"Error Applying Configuration Change: {tie.Message}", tie);
}
catch (ArgumentException ae)
{
throw new JsonException (
$"Error Applying Configuration Change ({PropertyInfo?.Name}): {ae.Message}",
ae
);
}
return PropertyValue != null;
}
/// <summary>
/// INTERNAL: Creates a copy of a ConfigProperty with the same metadata but no value.
/// </summary>
/// <param name="source">The source ConfigProperty.</param>
/// <returns>A new ConfigProperty instance.</returns>
internal static ConfigProperty CreateCopy (ConfigProperty source)
{
return new ConfigProperty
{
Immutable = false,View on GitHub (pinned to 2e47b11478)
Solutions
- Check the named property's declared type and ensure the config value deserializes to exactly that type.
- Verify any custom JsonConverter registered on the property returns the correct runtime type.
- Reproduce by setting the property directly in a small program to isolate type mismatch from config loading.
Defensive patterns
Strategy: validation
Validate before calling
// Confirm the deserialized value type matches the property type before Apply.
object? v = configProperty.PropertyValue;
Type? propType = configProperty.PropertyInfo?.PropertyType;
if (v is not null && propType is not null && v.GetType () != propType
&& Nullable.GetUnderlyingType (propType) != v.GetType ())
throw new InvalidOperationException ($"Type mismatch for {configProperty.PropertyInfo?.Name}"); Try / catch
try { ConfigurationManager.Apply (); }
catch (JsonException ex) when (ex.Message.Contains ("Error Applying Configuration Change") && ex.InnerException is ArgumentException)
{ /* fix the type mismatch in the config or converter */ } Prevention
- Ensure any custom JsonConverter returns the exact declared runtime type.
- Add a type-assertion in test config round-trips.
When it happens
Trigger: The deserialized PropertyValue has a runtime type incompatible with the static property (e.g. a Dictionary where a ConcurrentDictionary is expected, after a partial/failed deserialize), or DeepCloner produced a value of the wrong shape.
Common situations: A JsonConverter returned the wrong runtime type; a config schema change where the property's declared type was narrowed; a DeepCloner fallback that produced a default instance of an unrelated type.
Related errors
- Error Applying Configuration Change: {tie.InnerException.Mes
- Error Applying Configuration Change: {tie.Message}
- Invalid color name: {kvp.Key}
- Popovers must have ViewportSettings.Transparent and Viewport
- {propertyName}: Unexpected token when parsing Attribute: {re
AI-assisted analysis of tui-cs/Terminal.Gui@2e47b11478 (2026-08-13).
Data as JSON: /api/errors/9c7f08f3e9864dbf.
Report an issue: GitHub.