{"record":{"id":"cc5e569d9cf6f4a0","repo":"stride3d/stride","slug":"could-not-locate-program-files-folder","errorCode":null,"errorMessage":"Could not locate \"Program Files\" folder.","messagePattern":"Could not locate \"Program Files\" folder\\.","errorType":"exception","errorClass":"DirectoryNotFoundException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Direct3D12/WinPixNative.cs","lineNumber":84,"sourceCode":"    ///   This method is typically called before initializing GPU capture or profiling with Microsoft PIX.\n    ///   If the DLL is already loaded, calling this method has no effect.\n    /// </remarks>\n    public static void LoadPixGpuCapturer()\n    {\n        IntPtr moduleHandle = GetModuleHandle(CapturerDllName);\n        if (moduleHandle == IntPtr.Zero)\n        {\n            LoadLibrary(GetLatestWinPixGpuCapturerPath());\n        }\n\n        //\n        // Helper to locate the latest installed \"WinPixGpuCapturer.dll\".\n        //\n        static string GetLatestWinPixGpuCapturerPath()\n        {\n            string programFilesPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);\n            if (string.IsNullOrEmpty(programFilesPath))\n                throw new DirectoryNotFoundException(\"Could not locate \\\"Program Files\\\" folder.\");\n\n            string pixInstallationPath = Path.Combine(programFilesPath, \"Microsoft PIX\");\n            if (!Directory.Exists(pixInstallationPath))\n                throw new DirectoryNotFoundException($\"Microsoft PIX not found under \\\"{programFilesPath}\\\".\");\n\n            string newestVersionFound = null;\n\n            // Enumerate all subdirectories, looking for the one with the highest version number\n            foreach (var dir in Directory.EnumerateDirectories(pixInstallationPath))\n            {\n                var dirName = Path.GetFileName(dir);\n                if (string.IsNullOrEmpty(dirName))\n                    continue;\n\n                if (newestVersionFound is null || string.CompareOrdinal(newestVersionFound, dirName) < 0)\n                {\n                    newestVersionFound = dirName;\n                }","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Direct3D12/WinPixNative.cs#L66-L102","documentation":"Thrown by WinPixNative.LoadPixGpuCapturer (via GetLatestWinPixGpuCapturerPath) when Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) returns an empty string, so the PIX GPU capturer DLL cannot be located. This only runs on the PIX GPU-capture path, typically in debug builds.","triggerScenarios":"Enabling PIX GPU capture (via a debugger/Profiler attached capture request) on a system where the Program Files environment variable/special folder is not resolvable — e.g. running on non-Windows, a sandbox, or an environment with redirected/missing system folders.","commonSituations":"Capturing on Linux/macOS where the WinPIX path makes no sense; running under a service account or container with stripped environment variables; CI machines without standard Windows folder layout.","solutions":["Ensure the application runs on Windows with the standard Program Files folder available (SYSTEMDRIVE\\Program Files / %ProgramFiles%).","Disable PIX GPU capture (remove the capture trigger / PIX interop) on platforms where it cannot work.","Install Microsoft PIX so the path can be resolved and validated once the folder is found."],"exampleFix":"// before: PIX capture enabled unconditionally\nGraphicsDeviceFactory.EnableGPUCaptureAssertions = true;\n// after: guard for Windows PIX availability\nif (OperatingSystem.IsWindows() && Platform.IsWindowsDesktop)\n    GraphicsDeviceFactory.EnableGPUCaptureAssertions = true;","handlingStrategy":"fallback","validationCode":"if (!OperatingSystem.IsWindows())\n{\n    log.Info(\"PIX GPU capture unsupported on this OS; skipping\");\n    return;\n}\nvar pf = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);\nif (string.IsNullOrEmpty(pf)) { log.Warn(\"Program Files not resolvable; PIX capture skipped\"); return; }","typeGuard":"bool CanUsePixCapture() => OperatingSystem.IsWindows()\n    && !string.IsNullOrEmpty(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles));","tryCatchPattern":"try { WinPixNative.Initialize(); }\ncatch (DirectoryNotFoundException ex) { log.Warn(\"PIX capture unavailable: \" + ex.Message); }","preventionTips":["Enable PIX capture only on Windows desktop with the standard Program Files layout.","Skip capture hooks in non-Windows, container, and service contexts.","Wrap PIX interop initialization so capture failures never crash the app."],"tags":["windows","pix","gpu-capture","environment","file-not-found"],"backgroundTag":"directory-not-found","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}