stride3d/stride · error · InvalidOperationException

Unable to locate the executable for the selected version

Error message

Unable to locate the executable for the selected version

What it means

LocateMainExecutable resolves the main GameStudio/launcher executable for a selected Stride version. It first checks known per-version paths and finally falls back to probing a list of legacy executable names under InstallPath. When none of those files exist on disk, it throws this InvalidOperationException to signal the installed version cannot be located.

Solutions

  1. Verify InstallPath exists and contains the expected executable; reinstall the version if not
  2. Add the version's actual executable name to the known paths or GetMainExecutables legacy list
  3. Check the version's registry/package metadata points at the correct install directory
  4. Handle the exception in the UI by offering to re-download the version

Example fix

// before
var exe = version.LocateMainExecutable();
// after
if (!Directory.Exists(version.InstallPath) || !Directory.EnumerateFiles(version.InstallPath, "*.exe").Any())
{
    PromptReinstall(version);
    return;
}
var exe = version.LocateMainExecutable();
Defensive patterns

Strategy: validation

Validate before calling

var exePath = Directory.EnumerateFiles(installPath, "*.exe", SearchOption.TopDirectoryOnly).FirstOrDefault();
if (exePath == null || !Directory.Exists(installPath)) PromptReinstall(version);

Type guard

static bool IsVersionInstalled(StrideVersionViewModel v) => v?.InstallPath != null && Directory.Exists(v.InstallPath) && Directory.EnumerateFiles(v.InstallPath, "*.exe").Any();

Try / catch

try { var exe = version.LocateMainExecutable(); } catch (InvalidOperationException) { OfferReinstall(version); }

Prevention

When it happens

Trigger: Calling LocateMainExecutable for a version whose install directory is missing, incomplete, or whose executable name does not match any of the known or legacy paths (e.g. a renamed or restructured build).

Common situations: A version registered in the launcher but its folder deleted manually; a partially failed/interrupted install; very old or custom builds whose exe names predate the fallback list; case/extension mismatches (Stride.GameStudio.exe vs .Editor.exe) across historical versions.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/9c740383e839998a. Report an issue: GitHub.

Appendix: source

Thrown at sources/launcher/Stride.Launcher/ViewModels/StrideVersionViewModel.cs:297

        // Use the pre-computed editor → directory map from UpdateAvailableEditors.
        // Each editor may live in a different package directory and a different TFM subfolder
        // (e.g. net10.0 for Avalonia, net10.0-windows7.0 for WPF), so we store the fully
        // resolved directory rather than re-applying SelectedFramework here.
        foreach (var gameStudioExecutable in GetPreferredExecutableNames())
        {
            var editorName = Path.GetFileNameWithoutExtension(gameStudioExecutable);
            if (_editorToDir.TryGetValue(editorName, out var dir))
            {
                var gameStudioPath = Path.Combine(dir, gameStudioExecutable);
                if (File.Exists(gameStudioPath))
                    return gameStudioPath;
            }
        }

        // Otherwise, old-style fallback
        return GetMainExecutables().Select(x => Path.Combine(InstallPath, x)).FirstOrDefault(File.Exists)
            ?? throw new InvalidOperationException("Unable to locate the executable for the selected version");

        static IEnumerable<string> GetMainExecutables()
        {
            // some old paths used in previous versions
            if (OperatingSystem.IsWindows())
            {
            yield return @$"lib\net472\{GameStudioNames.Stride}.exe";
            }
        }
    }

    /// <summary>
    /// Returns the executable file names in preference order: the selected editor first, then the
    /// remaining editors in their default priority order.
    /// </summary>
    private IEnumerable<string> GetPreferredExecutableNames()
    {
        var ext = OperatingSystem.IsWindows() ? ".exe" : ".dll";

View on GitHub (pinned to 96fad776d2)