tui-cs/Terminal.Gui · error · JsonException

Error Applying Configuration Change: {tie.Message}

Error message

Error Applying Configuration Change: {tie.Message}

What it means

Thrown by ConfigProperty.Apply's TargetInvocationException catch when tie.InnerException is null — an unusual case where reflection wrapped an exception without an inner. The outer TargetInvocationException message is used directly. Functionally equivalent to error 30 but for the rare null-inner case.

Source

Thrown at Terminal.Gui/Configuration/ConfigProperty.cs:99

                // Use DeepCloner to create a deep copy of PropertyValue
                object? val = DeepCloner.DeepClone (PropertyValue);

                Debug.Assert (!Immutable);
                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)

View on GitHub (pinned to 2e47b11478)

Solutions

  1. Inspect the full ToString() of the thrown JsonException's InnerException (the TargetInvocationException itself) for the stack trace.
  2. Reproduce by calling the static setter directly with the same value to bypass reflection and get a clearer error.
  3. Report if it reproduces — the null-inner path is unexpected.
Defensive patterns

Strategy: try-catch

Try / catch

try { ConfigurationManager.Apply (); }
catch (JsonException ex) when (ex.InnerException is TargetInvocationException)
{ /* inspect ex.InnerException.ToString() for the real stack */ }

Prevention

When it happens

Trigger: A TargetInvocationException constructed without an inner exception (atypical); almost never seen in normal .NET reflection paths.

Common situations: A third-party property setter throwing a hand-built TargetInvocationException; an edge case in a dynamically emitted setter.

Related errors


AI-assisted analysis of tui-cs/Terminal.Gui@2e47b11478 (2026-08-13). Data as JSON: /api/errors/153a8d401b97105f. Report an issue: GitHub.