{"record":{"id":"636414bdf6d3a429","repo":"ppy/osu","slug":"attempting-to-add-a-new-component-to-a-target-cont","errorCode":null,"errorMessage":"Attempting to add a new component to a target container which is not supported by the current skin.","messagePattern":"Attempting to add a new component to a target container which is not supported by the current skin\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"warning","filePath":"osu.Game/Skinning/SkinnableContainer.cs","lineNumber":85,"sourceCode":"            cancellationSource?.Cancel();\r\n            cancellationSource = null;\r\n\r\n            LoadComponentAsync(content, wrapper =>\r\n            {\r\n                AddInternal(wrapper);\r\n                components.AddRange(wrapper.Children.OfType<ISerialisableDrawable>());\r\n                ComponentsLoaded = true;\r\n                OnComponentsLoaded?.Invoke(this);\r\n            }, (cancellationSource = new CancellationTokenSource()).Token);\r\n        }\r\n\r\n        /// <inheritdoc cref=\"ISerialisableDrawableContainer\"/>\r\n        /// <exception cref=\"NotSupportedException\">Thrown when attempting to add an element to a target which is not supported by the current skin.</exception>\r\n        /// <exception cref=\"ArgumentException\">Thrown if the provided instance is not a <see cref=\"Drawable\"/>.</exception>\r\n        public void Add(ISerialisableDrawable component)\r\n        {\r\n            if (content == null)\r\n                throw new NotSupportedException(\"Attempting to add a new component to a target container which is not supported by the current skin.\");\r\n\r\n            if (!(component is Drawable drawable))\r\n                throw new ArgumentException($\"Provided argument must be of type {nameof(Drawable)}.\", nameof(component));\r\n\r\n            content.Add(drawable);\r\n            components.Add(component);\r\n        }\r\n\r\n        /// <inheritdoc cref=\"ISerialisableDrawableContainer\"/>\r\n        /// <exception cref=\"NotSupportedException\">Thrown when attempting to add an element to a target which is not supported by the current skin.</exception>\r\n        /// <exception cref=\"ArgumentException\">Thrown if the provided instance is not a <see cref=\"Drawable\"/>.</exception>\r\n        public void Remove(ISerialisableDrawable component, bool disposeImmediately)\r\n        {\r\n            if (content == null)\r\n                throw new NotSupportedException(\"Attempting to remove a new component from a target container which is not supported by the current skin.\");\r\n\r\n            if (!(component is Drawable drawable))\r\n                throw new ArgumentException($\"Provided argument must be of type {nameof(Drawable)}.\", nameof(component));\r","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/ppy/osu/blob/d9c73e12adff2feaae4a3e158d36fe5883faf6ca/osu.Game/Skinning/SkinnableContainer.cs#L67-L103","documentation":"Thrown by SkinnableContainer.Add when the internal content drawable is null, meaning the current skin does not provide a target container for this skinnable target. Adding components is only possible when the skin exposes a backing container.","triggerScenarios":"Calling Add(component) on a SkinnableContainer whose skin does not supply a content container (e.g. a legacy skin that draws elements natively, or a target unsupported by the current skin type).","commonSituations":"Trying to customize components on a target the current skin renders non-declaratively; calling Add before components have loaded; skin switched to one without container support.","solutions":["Check the container supports custom components for the current skin before exposing Add UI (e.g. guard with a SupportsCustomComponents check or try/catch).","Switch to a skin that supports the target (modern/default skins typically do).","Ensure Reload/components-loaded completed before Add."],"exampleFix":"// before\ncontainer.Add(component); // throws if content == null\n\n// after\ntry { container.Add(component); }\ncatch (NotSupportedException) { Logger.Log(\"This skin does not support custom components here.\"); }","handlingStrategy":"validation","validationCode":"if (!container.ComponentsLoaded)\n    throw new InvalidOperationException(\"Container not loaded; cannot Add.\");","typeGuard":null,"tryCatchPattern":"try { container.Add(component); }\ncatch (NotSupportedException) { /* skin does not support custom components */ }","preventionTips":["Check the skin supports the target before exposing Add UI.","Ensure Reload completed before Add.","Switch to a modern/default skin for custom components."],"tags":["skinning","skinnable-container","api-misuse"],"backgroundTag":null,"analyzedSha":"d9c73e12adff2feaae4a3e158d36fe5883faf6ca","analyzedAt":"2026-08-13T14:12:54.015Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}