{"record":{"id":"addc1144cd52b998","repo":"dotnet/wpf","slug":"sr-invalidparameter","errorCode":null,"errorMessage":"SR.InvalidParameter","messagePattern":"SR\\.InvalidParameter","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsListView.cs","lineNumber":825,"sourceCode":"        RowOrColumnMajor ITableProvider.RowOrColumnMajor\n        {\n            get\n            {\n                return RowOrColumnMajor.RowMajor;\n            }\n        }\n\n\n        #endregion Table Pattern\n\n        #region MultipleViewPattern\n\n        // In the future use the official table for different views\n        string IMultipleViewProvider.GetViewName (int viewID)\n        {\n            if ( viewID < 0 || viewID > ListViewViews.Length )\n            {\n                throw new ArgumentException(SR.InvalidParameter);\n            }\n            return ListViewViews [viewID];\n        }\n\n        void IMultipleViewProvider.SetCurrentView (int viewID)\n        {\n            if ( viewID < 0 || viewID > ListViewViews.Length )\n            {\n                throw new ArgumentException(SR.InvalidParameter);\n            }\n            // App specific: App will provide us with the SupportedViews array\n            // How this would be done is TBD\n\n            // If requested view is in array, than do a Set\n            // {\n            //     return ListViewSetView(_hwnd, viewID);\n            // }\n","sourceCodeStart":807,"sourceCodeEnd":843,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsListView.cs#L807-L843","documentation":"WindowsListView's IMultipleViewProvider.GetViewName throws ArgumentException(SR.InvalidParameter) when the viewID is negative or greater than ListViewViews.Length. View IDs index into the fixed table of supported list-view views, so only IDs within that table are valid.","triggerScenarios":"Calling GetViewName(viewID) with viewID < 0 or viewID > ListViewViews.Length — e.g. passing an arbitrary/foreign view id instead of one obtained from GetSupportedViews.","commonSituations":"Scripts hard-coding view ids instead of enumerating supported views; view ids from a different control type; off-by-one when treating Length as a valid index.","solutions":["Enumerate MultipleViewPattern.GetSupportedViews() and use only those ids with GetViewName.","Validate 0 <= viewID < supported count before calling.","Catch ArgumentException and return/skip unknown view ids.","Do not use ListViewViews.Length itself as an id (valid ids are 0..Length)."],"exampleFix":"// before\nstring name = mv.GetViewName(9); // guessed id\n// after\nforeach (int id in mv.GetSupportedViews()) Console.WriteLine(mv.GetViewName(id));","handlingStrategy":"validation","validationCode":"int[] supported = ((MultipleViewPattern)element.GetCurrentPattern(MultipleViewPattern.Pattern)).GetSupportedViews();\nif (Array.IndexOf(supported, viewID) >= 0) { mv.GetViewName(viewID); }","typeGuard":null,"tryCatchPattern":"try { name = mv.GetViewName(viewID); } catch (ArgumentException) { /* unsupported view id */ }","preventionTips":["Only use ids from GetSupportedViews()","Never pass ids guessed or from another control","Treat Length of the view table as exclusive bound, not a valid id"],"tags":["ui-automation","multiple-view-pattern","invalid-argument"],"backgroundTag":"invalid-argument-value","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}