stride3d/stride · error · ArgumentException
Invalid type [ ]. Type must be assignable to Asset
Error message
Invalid type [{0}]. Type must be assignable to Asset What it means
The AssetImporterParameters constructor that takes a set of supported types validates each type is assignable to Asset; passing any non-asset type (or an interface/abstract-only set) throws ArgumentException naming 'supportedTypes'. It guards the importer's output-type selection map.
Solutions
- Ensure every element of supportedTypes is a class deriving from Stride.Core.Assets.Asset
- Fix the type passed at the construction site (check generic/reflection code)
- Add a pre-check with typeof(Asset).IsAssignableFrom(t) before constructing
- Remove placeholder/abstract types that are not concrete asset outputs
Example fix
// before
new AssetImporterParameters(new[] { typeof(object) });
// after
new AssetImporterParameters(new[] { typeof(TextureAsset) }); // derives from Asset Defensive patterns
Strategy: validation
Validate before calling
foreach (var t in supportedTypes)
if (t == null || !typeof(Asset).IsAssignableFrom(t))
throw new ArgumentException($"{t} is not an Asset"); Type guard
static bool IsAssetType(Type t) => t != null && typeof(Asset).IsAssignableFrom(t);
Try / catch
try { var p = new AssetImporterParameters(supportedTypes); }
catch (ArgumentException ex) when (ex.ParamName == "supportedTypes")
{ log.Error($"Invalid importer type: {ex.Message}"); } Prevention
- Use typeof(SomeConcreteAsset) literals where possible
- Filter reflection-derived types with IsAssignableFrom before passing
- Write a unit test that constructs importers with their declared types
When it happens
Trigger: Constructing AssetImporterParameters with a supportedTypes collection containing e.g. typeof(object), a custom non-Asset class, a struct, or null entries.
Common situations: Typo'd generic argument when wiring an importer; using a ViewModel/DTO type instead of the asset type; reflection-based code picking the wrong type from an assembly.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Unable to find the base
- Unable to find the graph corresponding to the base part
- The base is unset for the current node.
- No Collection item identifier associated to the given…
- An item has been added to a collection that does not have a…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/5757e3ad118d1878.
Report an issue: GitHub.
Appendix: source
Thrown at sources/assets/Stride.Core.Assets/AssetImporterParameters.cs:48
/// <param name="supportedTypes">The supported types.</param>
public AssetImporterParameters(params Type[] supportedTypes) : this((IEnumerable<Type>)supportedTypes)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="AssetImporterParameters"/> class.
/// </summary>
/// <param name="supportedTypes">The supported types.</param>
/// <exception cref="System.ArgumentNullException">supportedTypes</exception>
/// <exception cref="System.ArgumentException">Invalid type [{0}]. Type must be assignable to Asset.ToFormat(type);supportedTypes</exception>
public AssetImporterParameters(IEnumerable<Type> supportedTypes) : this()
{
ArgumentNullException.ThrowIfNull(supportedTypes);
foreach (var type in supportedTypes)
{
if (!typeof(Asset).IsAssignableFrom(type))
{
throw new ArgumentException("Invalid type [{0}]. Type must be assignable to Asset".ToFormat(type), nameof(supportedTypes));
}
SelectedOutputTypes[type] = true;
}
}
/// <summary>
/// Gets the import input parameters.
/// </summary>
/// <value>The import input parameters.</value>
public PropertyCollection InputParameters { get; private set; }
/// <summary>
/// Gets the selected output types.
/// </summary>
/// <value>The selected output types.</value>
public Dictionary<Type, bool> SelectedOutputTypes { get; private set; }
/// <summary>View on GitHub (pinned to 96fad776d2)