{"record":{"id":"8475aebea224eaed","repo":"stride3d/stride","slug":"could-not-find-executable-to-start-assembly-assemblylocation","errorCode":null,"errorMessage":"Could not find executable to start assembly [{assemblyLocation}]","messagePattern":"Could not find executable to start assembly \\[(.+?)\\]","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"sources/shared/LoaderToolLocator/LoaderToolLocator.cs","lineNumber":60,"sourceCode":"            var tfmPath = Path.GetDirectoryName(assemblyLocation);\n            if (tfmPath != null)\n            {\n                var parentPath = Path.GetDirectoryName(tfmPath);\n                if (parentPath != null && Path.GetFileName(parentPath).Equals(\"lib\", StringComparison.Ordinal))\n                {\n                    var packageRoot = Path.GetDirectoryName(parentPath);\n                    if (packageRoot != null)\n                    {\n                        var tfm = Path.GetFileName(tfmPath);\n                        var exeName = Path.GetFileNameWithoutExtension(assemblyLocation) + ExeExtension;\n                        var exeLocation = Path.Combine(packageRoot, \"tools\", tfm, exeName);\n                        if (File.Exists(exeLocation))\n                            return exeLocation;\n                    }\n                }\n            }\n\n            throw new FileNotFoundException($\"Could not find executable to start assembly [{assemblyLocation}]\");\n        }\n    }\n}\n","sourceCodeStart":42,"sourceCodeEnd":64,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shared/LoaderToolLocator/LoaderToolLocator.cs#L42-L64","documentation":"LoaderToolLocator.GetExecutable searches a set of candidate directories for the executable that corresponds to a given managed assembly location and returns the first path that exists. When none of the candidates exist on disk, it gives up with a FileNotFoundException naming the assembly. This signals that the tool's companion native/host executable is missing or not deployed alongside the assembly.","triggerScenarios":"Calling GetExecutable(assemblyLocation) when File.Exists() fails for every candidate path built from the assembly location (e.g. wrong build output directory, exe not copied to output, wrong runtime identifier folder).","commonSituations":"Running a tool from a partial publish output; moving the assembly exe away from its native loaders; switching RID/platform folders (e.g. win-x64 vs linux-x64) without redeploying; copying just the .dll without the .exe.","solutions":["Verify the companion executable exists next to the assembly (same directory or expected subfolder) and restore/copy it.","Rebuild or republish the tool so the host executable is included in the output (dotnet publish with the correct RID).","Pass the correct assemblyLocation path that points at the deployed output, not a stale or moved location.","Check that no antivirus/cleanup step deleted the executable after deployment."],"exampleFix":"// before\ncopy bin\\Debug\\MyTool.dll deploy\\\n// after\ndotnet publish MyTool -c Release -r win-x64 -o deploy\\   # publishes exe + native loaders together","handlingStrategy":"try-catch","validationCode":"var exeDir = Path.GetDirectoryName(assemblyLocation);\nif (exeDir == null || !Directory.GetFiles(exeDir, \"*\").Any(f => f.EndsWith(\".exe\", StringComparison.OrdinalIgnoreCase) || f.EndsWith(\".dll\", StringComparison.OrdinalIgnoreCase)))\n    throw new InvalidOperationException($\"Deployment directory {exeDir} looks incomplete; refusing to locate loader tool.\");","typeGuard":"static bool IsDeployedToolPresent(string assemblyLocation) =>\n    File.Exists(assemblyLocation) &&\n    Directory.EnumerateFiles(Path.GetDirectoryName(assemblyLocation)!, \"*\")\n        .Any(f => f.EndsWith(\".exe\", StringComparison.OrdinalIgnoreCase));","tryCatchPattern":"try\n{\n    var exe = LoaderToolLocator.GetExecutable(assemblyLocation);\n}\ncatch (FileNotFoundException ex) when (ex.Message.Contains(\"Could not find executable to start assembly\"))\n{\n    logger.Error($\"Tool executable missing for {assemblyLocation}; republish with 'dotnet publish -r <RID>'.\");\n    throw;\n}","preventionTips":["Always deploy with dotnet publish for the target RID instead of copying individual DLLs.","Add a post-build smoke test that calls GetExecutable in CI so missing exes fail the build.","Never move the assembly away from its native loaders/hosts after deployment."],"tags":["file-not-found","loader","deployment"],"backgroundTag":"file-not-found","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}