{"record":{"id":"866dc7ad531072ef","repo":"dotnet/wpf","slug":"microsoft-windows-controls-sr-ribbongroupspanel","errorCode":null,"errorMessage":"Microsoft.Windows.Controls.SR.RibbonGroupsPanel_InvalidRegistrationParameter","messagePattern":"Microsoft\\.Windows\\.Controls\\.SR\\.RibbonGroupsPanel_InvalidRegistrationParameter","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Controls/Ribbon/Primitives/RibbonGroupsPanel.cs","lineNumber":55,"sourceCode":"        /// <summary>\n        ///   Initializes static members of the RibbonGroupsContainer class.\n        /// </summary>\n        static RibbonGroupsPanel()\n        {\n            OrientationProperty.OverrideMetadata(typeof(RibbonGroupsPanel), new FrameworkPropertyMetadata(Orientation.Horizontal, null, new CoerceValueCallback(CoerceOrientation)));\n        }\n\n        #endregion\n\n        #region ISupportStarLayout Members\n\n        public void RegisterStarLayoutProvider(IProvideStarLayoutInfoBase starLayoutInfoProvider)\n        {\n            ArgumentNullException.ThrowIfNull(starLayoutInfoProvider);\n            IProvideStarLayoutInfo provider = starLayoutInfoProvider as IProvideStarLayoutInfo;\n            if (provider == null)\n            {\n                throw new ArgumentException(Microsoft.Windows.Controls.SR.RibbonGroupsPanel_InvalidRegistrationParameter, nameof(starLayoutInfoProvider));\n            }\n            if (!_registeredStarLayoutProviders.Contains(provider))\n            {\n                _registeredStarLayoutProviders.Add(provider);\n                InvalidateMeasure();\n            }\n        }\n\n        public void UnregisterStarLayoutProvider(IProvideStarLayoutInfoBase starLayoutInfoProvider)\n        {\n            ArgumentNullException.ThrowIfNull(starLayoutInfoProvider);\n            IProvideStarLayoutInfo provider = starLayoutInfoProvider as IProvideStarLayoutInfo;\n            if (provider == null)\n            {\n                throw new ArgumentException(Microsoft.Windows.Controls.SR.RibbonGroupsPanel_InvalidRegistrationParameter, nameof(starLayoutInfoProvider));\n            }\n            if (_registeredStarLayoutProviders.Contains(provider))\n            {","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Controls/Ribbon/Primitives/RibbonGroupsPanel.cs#L37-L73","documentation":"RibbonGroupsPanel.RegisterStarLayoutProvider only accepts objects implementing IProvideStarLayoutInfo (the full interface), not the base IProvideStarLayoutInfoBase. If the cast fails, an ArgumentException with resource key RibbonGroupsPanel_InvalidRegistrationParameter is thrown. This guards the panel's star-layout bookkeeping, which relies on members only present on the derived interface.","triggerScenarios":"Calling RegisterStarLayoutProvider with any object that implements only IProvideStarLayoutInfoBase (e.g. a custom ISupportStarLayout provider or a mock) instead of IProvideStarLayoutInfo.","commonSituations":"Custom ribbon panel/star-layout implementations, unit-test fakes built against the base interface, or code written against documentation that suggested the base type was sufficient.","solutions":["Pass an object that implements IProvideStarLayoutInfo (IProvideStarLayout, IProvideStarLayoutInfoBase, ISupportStarLayout) to RegisterStarLayoutProvider.","Before calling, check `provider is IProvideStarLayoutInfo` and skip or convert otherwise.","If you own the provider type, make it implement IProvideStarLayoutInfo instead of only IProvideStarLayoutInfoBase."],"exampleFix":"// before\npanel.RegisterStarLayoutProvider(myBaseProvider);\n// after\nif (myBaseProvider is IProvideStarLayoutInfo fullProvider)\n{\n    panel.RegisterStarLayoutProvider(fullProvider);\n}","handlingStrategy":"type-guard","validationCode":"if (provider is not IProvideStarLayoutInfo) throw new ArgumentException(nameof(provider));\npanel.RegisterStarLayoutProvider(provider);","typeGuard":"static bool IsValidStarLayoutProvider(IProvideStarLayoutInfoBase p) => p is IProvideStarLayoutInfo;","tryCatchPattern":"try { panel.RegisterStarLayoutProvider(provider); }\ncatch (ArgumentException ex) when (ex.ParamName == \"starLayoutInfoProvider\") { /* log / substitute valid provider */ }","preventionTips":["Type provider fields as IProvideStarLayoutInfo, not the base interface.","Pattern-match before register/unregister calls.","Test custom providers against the real panel in unit tests."],"tags":["wpf","ribbon","argumentexception"],"backgroundTag":"type-mismatch","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}