{"record":{"id":"9c7f08f3e9864dbf","repo":"tui-cs/Terminal.Gui","slug":"error-applying-configuration-change-propertyinfo","errorCode":null,"errorMessage":"Error Applying Configuration Change ({PropertyInfo?.Name}): {ae.Message}","messagePattern":"Error Applying Configuration Change \\((.+?)\\): (.+?)","errorType":"exception","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"Terminal.Gui/Configuration/ConfigProperty.cs","lineNumber":103,"sourceCode":"                PropertyInfo.SetValue (null, val);\n\n            }\n        }\n        catch (TargetInvocationException tie)\n        {\n            if (tie.InnerException is { })\n            {\n                throw new JsonException (\n                                         $\"Error Applying Configuration Change: {tie.InnerException.Message}\",\n                                         tie.InnerException\n                                        );\n            }\n\n            throw new JsonException ($\"Error Applying Configuration Change: {tie.Message}\", tie);\n        }\n        catch (ArgumentException ae)\n        {\n            throw new JsonException (\n                                     $\"Error Applying Configuration Change ({PropertyInfo?.Name}): {ae.Message}\",\n                                     ae\n                                    );\n        }\n\n        return PropertyValue != null;\n    }\n\n    /// <summary>\n    /// INTERNAL: Creates a copy of a ConfigProperty with the same metadata but no value.\n    /// </summary>\n    /// <param name=\"source\">The source ConfigProperty.</param>\n    /// <returns>A new ConfigProperty instance.</returns>\n    internal static ConfigProperty CreateCopy (ConfigProperty source)\n    {\n        return new ConfigProperty\n        {\n            Immutable = false,","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/tui-cs/Terminal.Gui/blob/2e47b11478db083499917f2ad27c34d30efb0df1/Terminal.Gui/Configuration/ConfigProperty.cs#L85-L121","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Confirm the deserialized value type matches the property type before Apply.\nobject? v = configProperty.PropertyValue;\nType? propType = configProperty.PropertyInfo?.PropertyType;\nif (v is not null && propType is not null && v.GetType () != propType\n    && Nullable.GetUnderlyingType (propType) != v.GetType ())\n    throw new InvalidOperationException ($\"Type mismatch for {configProperty.PropertyInfo?.Name}\");","typeGuard":null,"tryCatchPattern":"try { ConfigurationManager.Apply (); }\ncatch (JsonException ex) when (ex.Message.Contains (\"Error Applying Configuration Change\") && ex.InnerException is ArgumentException)\n{ /* fix the type mismatch in the config or converter */ }","preventionTips":["Ensure any custom JsonConverter returns the exact declared runtime type.","Add a type-assertion in test config round-trips."],"tags":["configuration","apply","argument-exception","type-mismatch"],"backgroundTag":null,"analyzedSha":"2e47b11478db083499917f2ad27c34d30efb0df1","analyzedAt":"2026-08-13T19:20:08.826Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}