{"record":{"id":"c813c8558b92b4a2","repo":"lepoco/wpfui","slug":"the-updateactualwidth-method-was-not-found","errorCode":null,"errorMessage":"The `UpdateActualWidth` method was not found.","messagePattern":"The `UpdateActualWidth` method was not found\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"critical","filePath":"src/Wpf.Ui/Controls/GridView/GridViewColumn.cs","lineNumber":48,"sourceCode":"{\n    // use reflection to get the `_desiredWidth` private field.\n    private static readonly Lazy<FieldInfo> _desiredWidthField = new(() =>\n        typeof(System.Windows.Controls.GridViewColumn).GetField(\n            \"_desiredWidth\",\n            BindingFlags.NonPublic | BindingFlags.Instance\n        ) ?? throw new InvalidOperationException(\"The `_desiredWidth` field was not found.\")\n    );\n\n    private static FieldInfo DesiredWidthField => _desiredWidthField.Value;\n\n    // use reflection to get the `UpdateActualWidth` private method.\n    private static readonly Lazy<MethodInfo> _updateActualWidthMethod = new(() =>\n    {\n        MethodInfo methodInfo =\n            typeof(System.Windows.Controls.GridViewColumn).GetMethod(\n                \"UpdateActualWidth\",\n                BindingFlags.NonPublic | BindingFlags.Instance\n            ) ?? throw new InvalidOperationException(\"The `UpdateActualWidth` method was not found.\");\n        return methodInfo;\n    });\n\n    private static MethodInfo UpdateActualWidthMethod => _updateActualWidthMethod.Value;\n\n    /// <summary>\n    /// Updates the desired width of the column to be clamped between MinWidth and MaxWidth).\n    /// </summary>\n    /// <remarks>\n    /// Uses reflection to directly set the private `_desiredWidth` field on the `System.Windows.Controls.GridViewColumn`.\n    /// </remarks>\n    /// <exception cref=\"InvalidOperationException\">\n    /// Thrown if reflection fails to access the `_desiredWidth` field\n    /// </exception>\n    internal void UpdateDesiredWidth()\n    {\n        double currentWidth = (double)(\n            DesiredWidthField.GetValue(this)","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/lepoco/wpfui/blob/ffebacd61058170cf63864b7d5aa730cffff848a/src/Wpf.Ui/Controls/GridView/GridViewColumn.cs#L30-L66","documentation":"Thrown lazily on first access of UpdateActualWidthMethod when reflection over System.Windows.Controls.GridViewColumn cannot find the private instance method 'UpdateActualWidth'. Companion to the _desiredWidth field guard (error 24); both are required for the column-width clamping feature. A failure means the WPF runtime changed its internals and the feature is incompatible with the loaded runtime.","triggerScenarios":"First invocation of UpdateDesiredWidth on a .NET / WPF build where 'UpdateActualWidth' was renamed or removed; running under trimming/AOT that stripped the method metadata.","commonSituations":"Framework upgrade that refactored GridViewColumn; AOT-published WPF app; preview runtime where internal APIs shifted.","solutions":["Target a .NET / WPF version whose GridViewColumn exposes 'UpdateActualWidth'.","Avoid the ui:GridViewColumn MinWidth/MaxWidth feature until the library supports your runtime.","Ensure reflection metadata is not trimmed (do not publish ready-to-run / AOT for this assembly).","File an upstream issue with the runtime version so the method lookup can be patched."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { col.UpdateDesiredWidth(); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"UpdateActualWidth\"))\n{\n    Logger.Warn($\"Runtime missing UpdateActualWidth: {ex.Message}\");\n    // disable MinWidth/MaxWidth clamping\n}","preventionTips":["Target a .NET / WPF version whose GridViewColumn exposes UpdateActualWidth.","Avoid ready-to-run / AOT publication for this assembly.","Track upstream compatibility when moving to newer runtimes."],"tags":["wpf","gridview","reflection","version-compatibility","internals"],"backgroundTag":null,"analyzedSha":"ffebacd61058170cf63864b7d5aa730cffff848a","analyzedAt":"2026-08-13T21:36:01.370Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}