stride3d/stride · error · ArgumentException
Assets must have the same Id.
Error message
Assets must have the same Id.
What it means
AssetViewModel.UpdateAsset replaces the internal asset with a new one and requires the replacement to be the same identity — i.e. share the same Id — because it is an in-place update of an existing asset item, not a replacement with a different asset. A mismatched Id is a caller error, raised as ArgumentException.
Solutions
- Ensure the new asset was loaded from the same asset item so its Id matches; do not pass clones or duplicates.
- If Ids legitimately differ, remove/re-add the asset instead of calling UpdateAsset.
- Re-import or re-save the source file so it keeps the original asset Id.
Example fix
// before
if (loadedAsset.Id != currentAsset.Id) { /* silently update */ }
vm.UpdateAsset(loadedAsset, logger);
// after
if (loadedAsset.Id != vm.AssetItem.Asset.Id)
throw new InvalidOperationException("Reloaded asset is a copy, not the same asset.");
vm.UpdateAsset(loadedAsset, logger); Defensive patterns
Strategy: validation
Validate before calling
if (newAsset.Id != vm.AssetItem.Asset.Id) { logger.Error("Cannot update: asset Ids differ (copy vs original)"); return; } Type guard
bool IsSameAssetIdentity(AssetViewModel vm, Asset a) => a.Id == vm.AssetItem.Asset.Id;
Try / catch
try { vm.UpdateAsset(newAsset, logger); }
catch (ArgumentException ex) { logger.Error(ex, "Reloaded asset has a different Id; it is not an update of this asset"); } Prevention
- Save updates in place so the asset keeps its Guid
- Detect duplicated asset files before loading them
- For legitimately different assets use remove/add, not UpdateAsset
When it happens
Trigger: Calling UpdateAsset(newAsset, logger) with an Asset whose Id differs from AssetItem.Asset.Id, e.g. deserializing a copy/duplicate of the asset instead of the updated version of the same asset.
Common situations: Reload/reimport workflows where the file was duplicated (getting a new Guid) instead of saved in place; loading an older file version with a different Id; mixing assets between packages.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- url cannot be null or empty.
- The given directory is not contained in the given package.
- Assets must have the same source.
- The given id cannot be found in the root parts of this…
- Unable to find the base
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/b688f62a8a49b216.
Report an issue: GitHub.
Appendix: source
Thrown at sources/editor/Stride.Core.Assets.Editor/ViewModel/AssetViewModel.cs:519
if (newName == name)
return;
using (var transaction = UndoRedoService.CreateTransaction())
{
string previousName = name;
UpdateUrl(package, directory, newName);
UndoRedoService.SetName(transaction, $"Rename asset '{previousName}' to '{newName}'");
}
}
/// <summary>
/// Replace the internal asset with the one provided, this function expects the two assets to have the same identity
/// </summary>
/// <exception cref="ArgumentException">The asset provided does not have the same identity as the current one</exception>
public void UpdateAsset(Asset newAsset, ILogger loggerResult)
{
if (newAsset.Id != AssetItem.Asset.Id)
throw new ArgumentException("Assets must have the same Id.");
if (newAsset.MainSource != AssetItem.Asset.MainSource)
throw new ArgumentException("Assets must have the same source.");
var newAssetItem = AssetItem.Clone(newAsset: newAsset);
package.Assets.Remove(AssetItem);
package.Assets.Add(newAssetItem);
AssetItem = newAssetItem;
PropertyGraph?.Dispose();
Session.GraphContainer.UnregisterGraph(assetItem.Id);
PropertyGraph = Session.GraphContainer.InitializeAsset(assetItem, loggerResult);
if (PropertyGraph != null)
{
PropertyGraph.BaseContentChanged += BaseContentChanged;View on GitHub (pinned to 96fad776d2)