stride3d/stride · error · InvalidOperationException
The name of a project cannot be set
Error message
The name of a project cannot be set
What it means
ProjectViewModel exposes the project name as read-only by reflecting SolutionProject.Name. The Name setter throws InvalidOperationException whenever a different value is assigned, because a project's name cannot be changed through this view model. This enforces the invariant that project identity is managed by the solution, not the view model.
Solutions
- Do not attempt to rename projects via ProjectViewModel.Name; use the solution-level rename API for projects.
- Make the UI mark project names as read-only so the setter is never invoked.
- Check the item type before binding a rename command (only allow renaming non-project items).
- Remove the setter call from serialization/import code paths that iterate all properties.
Example fix
// before
viewModel.Name = newName; // throws for projects
// after
if (viewModel is ProjectViewModel)
throw new NotSupportedException("Rename projects via the solution, not ProjectViewModel");
viewModel.Name = newName; Defensive patterns
Strategy: validation
Validate before calling
if (viewModel is ProjectViewModel)
throw new NotSupportedException("Projects cannot be renamed via ProjectViewModel"); Type guard
bool isProject = item is ProjectViewModel;
Try / catch
try { vm.Name = newName; }
catch (InvalidOperationException) { /* read-only: use solution rename API */ } Prevention
- Bind Name as read-only for project tree nodes
- Only enable rename UI for non-project items
- Never two-way bind ProjectViewModel.Name
When it happens
Trigger: Assigning any string other than the current Name to ProjectViewModel.Name, e.g. through data binding, a rename UI, or serialization code writing back properties.
Common situations: A generic property-grid or rename dialog tries to rename every item in the solution tree including projects; two-way WPF binding writes back the same-looking name with different casing/whitespace.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Cannot change the name of a EntityHierarchyRootViewModel…
- Invoking ShouldStayOpen before the work is finished.
- Parent cannot be null
- The entity to insert has already been destroyed
- The folder being deleted is not empty.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/6f695b88fb5f7dc5.
Report an issue: GitHub.
Appendix: source
Thrown at sources/editor/Stride.Core.Assets.Editor/ViewModel/ProjectViewModel.cs:57
}
}
// TODO: For the moment we consider that a project has only a single parent profile. Sharing project in several profile is not supported.
public class ProjectViewModel : PackageViewModel
{
private bool isCurrentProject;
public ProjectViewModel(SessionViewModel session, SolutionProject project, bool packageAlreadyInSession)
: base(session, project, packageAlreadyInSession)
{
content.Add(Code = new ProjectCodeViewModel(this));
}
public SolutionProject Project => (SolutionProject)PackageContainer;
public ProjectCodeViewModel Code { get; }
public override string Name { get { return Project.Name; } set { if (value != Name) throw new InvalidOperationException("The name of a project cannot be set"); } }
public UFile ProjectPath => Project.FullPath;
// TODO CSPROJ=XKPKG
public ProjectType Type => Project.Type;
public PlatformType Platform => Project.Platform;
/// <summary>
/// Gets the generic type (either PlatformType or ProjectType)
/// </summary>
/// TODO: Remove this code as this is an ugly workaround
public object GenericType => Platform != PlatformType.Shared ? (object)Platform : Type;
public bool IsCurrentProject
{
get { return isCurrentProject; }
internal setView on GitHub (pinned to 96fad776d2)