stride3d/stride · error · InvalidOperationException
Cannot change an Asset Object Id once it is locked by a…
Error message
Cannot change an Asset Object Id once it is locked by a package
What it means
Setter guard on Asset.Id: the asset has been added to a package, which locks its identity (IsIdLocked), and code attempted to assign a different AssetId. Asset identity is immutable once the asset belongs to a package so references stay stable.
Solutions
- Remove the asset from its package before changing the Id, then re-add it
- Clone the asset into a new AssetItem if a distinct identity is required
- Fix the code path that reassigns Id after package registration
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at sources/assets/Stride.Core.Assets/Asset.cs:60 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/e6a94d55ddae10fe.
Report an issue: GitHub.
Appendix: source
Thrown at sources/assets/Stride.Core.Assets/Asset.cs:60
/// <summary>
/// Gets or sets the unique identifier of this asset.
/// </summary>
/// <value>The identifier.</value>
/// <exception cref="InvalidOperationException">Cannot change an Asset Object Id once it is locked</exception>
[DataMember(-10000)]
[NonOverridable]
[Display(Browsable = false)]
public AssetId Id
{
// Note: Please keep this code in sync with Package class
get
{
return id;
}
set
{
if (value != id && IsIdLocked)
throw new InvalidOperationException("Cannot change an Asset Object Id once it is locked by a package");
id = value;
}
}
// Note: Please keep this code in sync with Package class
/// <summary>
/// Gets or sets the version number for this asset, used internally when migrating assets.
/// </summary>
/// <value>The version.</value>
[DataMember(-8000, DataMemberMode.Assign)]
[DataStyle(DataStyle.Compact)]
[Display(Browsable = false)]
[DefaultValue(null)]
[NonOverridable]
[NonIdentifiableCollectionItems]
public Dictionary<string, PackageVersion>? SerializedVersion { get; set; }
View on GitHub (pinned to 96fad776d2)