ppy/osu · warning · NotSupportedException
Attempting to remove a new component from a target container
Error message
Attempting to remove a new component from a target container which is not supported by the current skin.
What it means
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.
Source
Thrown at osu.Game/Skinning/SkinnableContainer.cs:100
public void Add(ISerialisableDrawable component)
{
if (content == null)
throw new NotSupportedException("Attempting to add a new component to a target container which is not supported by the current skin.");
if (!(component is Drawable drawable))
throw new ArgumentException($"Provided argument must be of type {nameof(Drawable)}.", nameof(component));
content.Add(drawable);
components.Add(component);
}
/// <inheritdoc cref="ISerialisableDrawableContainer"/>
/// <exception cref="NotSupportedException">Thrown when attempting to add an element to a target which is not supported by the current skin.</exception>
/// <exception cref="ArgumentException">Thrown if the provided instance is not a <see cref="Drawable"/>.</exception>
public void Remove(ISerialisableDrawable component, bool disposeImmediately)
{
if (content == null)
throw new NotSupportedException("Attempting to remove a new component from a target container which is not supported by the current skin.");
if (!(component is Drawable drawable))
throw new ArgumentException($"Provided argument must be of type {nameof(Drawable)}.", nameof(component));
content.Remove(drawable, disposeImmediately);
components.Remove(component);
}
protected override void SkinChanged(ISkinSource skin)
{
base.SkinChanged(skin);
Reload();
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
View on GitHub (pinned to d9c73e12ad)
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.
Example fix
// before
container.Remove(component, true);
// after
try { container.Remove(component, true); }
catch (NotSupportedException) { Logger.Log("Removal not supported by current skin."); } Defensive patterns
Strategy: validation
Validate before calling
if (!container.ComponentsLoaded)
throw new InvalidOperationException("Container not loaded; cannot Remove."); Try / catch
try { container.Remove(component, true); }
catch (NotSupportedException) { /* skin does not support custom components */ } Prevention
- Guard Remove UI against non-container skins.
- Ensure the container is loaded before Remove.
- Switch to a supporting skin for component management.
When it happens
Trigger: Calling Remove(component, disposeImmediately) on a SkinnableContainer whose skin supplies no content container.
Common situations: 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.
Related errors
- Attempting to add a new component to a target container whic
- Attempting to use this setter will not work correctly. Use s
- A {nameof(PoolableSkinnableSample)} cannot be applied multip
- Setting {nameof(CurrentSkin)}'s value directly is not suppor
- Provided argument must be of type {nameof(Drawable)}.
AI-assisted analysis of ppy/osu@d9c73e12ad (2026-08-13).
Data as JSON: /api/errors/a7a66643a72e65f9.
Report an issue: GitHub.