{"record":{"id":"a7a66643a72e65f9","repo":"ppy/osu","slug":"attempting-to-remove-a-new-component-from-a-target","errorCode":null,"errorMessage":"Attempting to remove a new component from a target container which is not supported by the current skin.","messagePattern":"Attempting to remove a new component from 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":100,"sourceCode":"        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\n\r\n            content.Remove(drawable, disposeImmediately);\r\n            components.Remove(component);\r\n        }\r\n\r\n        protected override void SkinChanged(ISkinSource skin)\r\n        {\r\n            base.SkinChanged(skin);\r\n\r\n            Reload();\r\n        }\r\n\r\n        protected override void Dispose(bool isDisposing)\r\n        {\r\n            base.Dispose(isDisposing);\r","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/ppy/osu/blob/d9c73e12adff2feaae4a3e158d36fe5883faf6ca/osu.Game/Skinning/SkinnableContainer.cs#L82-L118","documentation":"Thrown by SkinnableContainer.Remove when content is null, symmetric to the Add guard: the current skin does not expose a target container, so removal is not supported. Mirrors 'Attempting to add a new component...' for the removal path.","triggerScenarios":"Calling Remove(component, disposeImmediately) on a SkinnableContainer whose skin supplies no content container.","commonSituations":"Skin switched to a non-container skin while UI still offers remove; calling Remove before components loaded; operating on a target the legacy skin draws natively.","solutions":["Guard Remove UI against skins without container support.","Switch to a skin that supports the target before allowing removal.","Ensure the container is loaded (Reload completed) before Remove."],"exampleFix":"// before\ncontainer.Remove(component, true);\n\n// after\ntry { container.Remove(component, true); }\ncatch (NotSupportedException) { Logger.Log(\"Removal not supported by current skin.\"); }","handlingStrategy":"validation","validationCode":"if (!container.ComponentsLoaded)\n    throw new InvalidOperationException(\"Container not loaded; cannot Remove.\");","typeGuard":null,"tryCatchPattern":"try { container.Remove(component, true); }\ncatch (NotSupportedException) { /* skin does not support custom components */ }","preventionTips":["Guard Remove UI against non-container skins.","Ensure the container is loaded before Remove.","Switch to a supporting skin for component management."],"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"}