stride3d/stride · error · ArgumentNullException
url cannot be null or empty.
Error message
url cannot be null or empty.
What it means
The protected UrlReferenceBase(string url) constructor requires a non-empty asset URL. Stride throws ArgumentNullException when the url parameter is null, empty, or whitespace, because a URL reference with no URL cannot point at any asset. It is a fail-fast guard for all concrete reference types (e.g. UrlReference<T>) deriving from UrlReferenceBase.
Solutions
- Pass a valid, non-empty asset URL (e.g. relative to the virtual file system, like 'myScene.sdscene') to the reference constructor.
- Check the source of the string before constructing: if it comes from a config/property lookup, handle the missing value before creating the reference.
- If the reference is legitimately absent, keep the field null (UrlReference is a struct and default is valid) rather than constructing with an empty URL.
Example fix
// before
var reference = new UrlReference<Scene>(config.ScenePath); // throws if ScenePath null/empty
// after
if (!string.IsNullOrWhiteSpace(config.ScenePath))
reference = new UrlReference<Scene>(config.ScenePath); Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrWhiteSpace(url))
throw new ArgumentException("A non-empty asset URL is required to create a UrlReference.", nameof(url));
var reference = new UrlReference<Scene>(url); Type guard
static bool IsValidUrlReferenceSource(string? url) => !string.IsNullOrWhiteSpace(url);
Prevention
- Never construct UrlReference with an empty string; leave it at default instead.
- Validate config/property sources of asset paths before building references.
- Centralize reference construction in a factory that validates the URL once.
When it happens
Trigger: Calling new UrlReference<T>(null), new UrlReference<T>(""), or new UrlReference<T>(" ") — any derived class constructor invoked with a null/whitespace url string, typically from deserialization or code building references programmatically.
Common situations: Constructing asset references in editor tooling or build scripts where the URL string comes from an uninitialized variable, a failed file-path lookup, or a properties file that omitted the asset path.
Related errors
- ArgumentNullException: value
- The asset directory cannot be null before deleting an asset.
- The given directory is not contained in the given package.
- Assets must have the same Id.
- Assets must have the same source.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/22584ac0cc5b7a4a.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core.Serialization/Serialization/UrlReferenceBase.cs:33
public abstract class UrlReferenceBase : IReference, IUrlReference
{
/// <summary>
/// Create a new <see cref="UrlReferenceBase"/> instance.
/// </summary>
protected UrlReferenceBase()
{
}
/// <summary>
/// Create a new <see cref="UrlReferenceBase"/> instance.
/// </summary>
/// <param name="url"></param>
/// <exception cref="ArgumentNullException">If <paramref name="url"/> is <c>null</c> or empty.</exception>
protected UrlReferenceBase(string url)
{
if (string.IsNullOrWhiteSpace(url))
{
throw new ArgumentNullException(nameof(url), $"{nameof(url)} cannot be null or empty.");
}
this.Url = url;
}
/// <summary>
/// Create a new <see cref="UrlReferenceBase"/> instance.
/// </summary>
/// <exception cref="ArgumentNullException">If <paramref name="url"/> is <c>null</c> or empty.</exception>
protected UrlReferenceBase(AssetId id, string url)
{
if (string.IsNullOrWhiteSpace(url))
{
throw new ArgumentNullException(nameof(url), $"{nameof(url)} cannot be null or empty.");
}
this.Url = url;
this.Id = id;View on GitHub (pinned to 96fad776d2)