stride3d/stride · error · ArgumentException
Assets must have the same source.
Error message
Assets must have the same source.
What it means
In the same UpdateAsset flow, the editor also requires the new asset's MainSource to equal the current asset's MainSource. The update path only refreshes the asset in place and cannot swap its primary source; a different source means the caller is handing in an asset that is not really an updated version of this one, so an ArgumentException is thrown.
Solutions
- Reload the asset preserving its original MainSource; only content/properties should differ.
- If the source must change, delete the asset and create a new one rather than using UpdateAsset.
- Log/compare newAsset.MainSource vs AssetItem.Asset.MainSource before calling to detect the divergence early.
Example fix
// before
vm.UpdateAsset(reloadedAsset, logger); // reloadedAsset.MainSource changed
// after
if (reloadedAsset.MainSource != vm.AssetItem.Asset.MainSource)
{
logger.Error("Asset source changed; recreate the asset instead of updating.");
return;
}
vm.UpdateAsset(reloadedAsset, logger); Defensive patterns
Strategy: validation
Validate before calling
if (newAsset.MainSource != vm.AssetItem.Asset.MainSource) { logger.Error("Cannot update: asset MainSource changed; recreate the asset"); return; } Type guard
bool IsUpdateCompatible(AssetViewModel vm, Asset a) => a.Id == vm.AssetItem.Asset.Id && a.MainSource == vm.AssetItem.Asset.MainSource;
Try / catch
try { vm.UpdateAsset(newAsset, logger); }
catch (ArgumentException ex) { logger.Error(ex, "Asset MainSource mismatch; delete and recreate instead"); } Prevention
- Never repoint an asset's source file and then attempt an in-place reload
- Verify MainSource equality in re-import pipelines before calling UpdateAsset
- Treat source changes as create-new-asset workflows
When it happens
Trigger: Calling UpdateAsset with an asset whose MainSource differs from the current asset's — e.g. reloading a file whose source reference changed, or passing an entirely different asset type/file.
Common situations: Re-importing an asset after its source file was relocated or repointed; template/archetype reloads that rebuilt the asset with different source settings; hand-crafted Asset objects in tooling.
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 Id.
- 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/2719edc2e6345317.
Report an issue: GitHub.
Appendix: source
Thrown at sources/editor/Stride.Core.Assets.Editor/ViewModel/AssetViewModel.cs:522
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;
PropertyGraph.Changed += AssetPropertyChanged;
PropertyGraph.ItemChanged += AssetPropertyChanged;
PropertyGraph.Initialize();View on GitHub (pinned to 96fad776d2)