{"record":{"id":"ef4180713f1b4d5c","repo":"microsoft/aspire","slug":"failed-to-create-process-filename","errorCode":null,"errorMessage":"Failed to create process: {fileName}","messagePattern":"Failed to create process: (.+?)","errorType":"exception","errorClass":"Win32Exception","httpStatus":null,"severity":"error","filePath":"src/Aspire.Cli/Processes/WindowsProcessInterop.cs","lineNumber":476,"sourceCode":"                    {\n                        if (environment is not null)\n                        {\n                            envBlockHandle = BuildEnvironmentBlock(environment);\n                        }\n\n                        if (!CreateProcessW(\n                            null,\n                            commandLine,\n                            nint.Zero,\n                            nint.Zero,\n                            bInheritHandles: true,\n                            flags,\n                            envBlockHandle,\n                            workingDirectory,\n                            ref si,\n                            out var pi))\n                        {\n                            throw new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error(), $\"Failed to create process: {fileName}\");\n                        }\n\n                        return pi;\n                    }\n                    finally\n                    {\n                        if (envBlockHandle != nint.Zero)\n                        {\n                            Marshal.FreeHGlobal(envBlockHandle);\n                        }\n                    }\n                }\n                finally\n                {\n                    if (pinnedJobHandles.IsAllocated)\n                    {\n                        pinnedJobHandles.Free();\n                    }","sourceCodeStart":458,"sourceCodeEnd":494,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Cli/Processes/WindowsProcessInterop.cs#L458-L494","documentation":"This is thrown when the native CreateProcess call fails while the Aspire CLI spawns a child process on Windows using extended startup attributes (attribute list, environment block, job assignment). The Win32Exception carries the OS error code and the message names the executable that could not be started. It is the final gate after all attribute-list setup succeeded.","triggerScenarios":"Calling the WindowsProcessInterop process-creation helper (used for dashboard and other child launches with killOnParentExit: true) where CreateProcess returns false — e.g. ERROR_FILE_NOT_FOUND for the executable path, ERROR_ACCESS_DENIED, or invalid working directory.","commonSituations":"The managed dashboard binary or target executable path is wrong or was deleted mid-run; working directory does not exist; PATH/bundle extraction issues; antivirus quarantining the executable; corrupted bundle layout after a partial 'aspire setup' extraction.","solutions":["Check the inner Win32 error: ERROR_FILE_NOT_FOUND/ERROR_PATH_NOT_FOUND means verify the executable path exists (run 'aspire setup --force' to re-extract the CLI bundle).","ERROR_ACCESS_DENIED: check file permissions and antivirus quarantining of the binary.","Verify the working directory passed to the spawn exists and is accessible.","Reinstall or repair the Aspire CLI if the bundle layout is corrupted."],"exampleFix":"// before: spawning with a stale/missing bundle path\n// after: force re-extraction, then retry\nawait bundleService.EnsureExtractedAndAcquireLayoutAsync(\"cli\", \"force: true\", ct); // run 'aspire setup --force' equivalent\nvar process = await layoutProcessRunner.StartAsync(managedPath, args, ...);","handlingStrategy":"validation","validationCode":"if (!File.Exists(managedPath))\n{\n    throw new InvalidOperationException($\"Executable not found before spawn: {managedPath}. Run 'aspire setup --force'.\");\n}\nif (!Directory.Exists(workingDirectory))\n{\n    throw new InvalidOperationException($\"Working directory does not exist: {workingDirectory}\");\n}","typeGuard":null,"tryCatchPattern":"catch (Win32Exception ex)\n{\n    var reason = ex.ErrorCode switch\n    {\n        2 or 3 => \"executable or path not found — repair the bundle\",\n        5 => \"access denied — check permissions/antivirus\",\n        267 => \"invalid working directory\",\n        _ => \"unexpected Win32 failure\"\n    };\n    throw new InvalidOperationException($\"CreateProcess failed: {reason}\", ex);\n}","preventionTips":["Validate the executable path and working directory before spawning.","Run 'aspire setup --force' after any manual tampering with the bundle.","Keep antivirus exclusions for the CLI install directory."],"tags":["windows","win32","process-management","createprocess","cli"],"backgroundTag":"win32-api-call-failed","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}