{"record":{"id":"48634d495df3b9c2","repo":"Orbmu2k/nvidiaProfileInspector","slug":"drs-loadsettings","errorCode":null,"errorMessage":"DRS_LoadSettings","messagePattern":"DRS_LoadSettings","errorType":"exception","errorClass":"NvapiException","httpStatus":null,"severity":"error","filePath":"nvidiaProfileInspector/Common/DrsSessionScope.cs","lineNumber":39,"sourceCode":"                if (!HoldSession || forceNonGlobalSession)\n                    return NonGlobalDrsSession<T>(action, preventLoadSettings);\n\n\n                if (GlobalSession == IntPtr.Zero)\n                {\n\n#pragma warning disable CS0420\n                    var csRes = nvw.Instance.DRS_CreateSession(ref GlobalSession);\n#pragma warning restore CS0420\n\n                    if (csRes != NvAPI_Status.NVAPI_OK)\n                        throw new NvapiException(\"DRS_CreateSession\", csRes);\n\n                    if (!preventLoadSettings)\n                    {\n                        var nvRes = nvw.Instance.DRS_LoadSettings(GlobalSession);\n                        if (nvRes != NvAPI_Status.NVAPI_OK)\n                            throw new NvapiException(\"DRS_LoadSettings\", nvRes);\n                    }\n                }\n            }\n\n            if (GlobalSession != IntPtr.Zero)\n            {\n                return action(GlobalSession);\n            }\n\n            throw new Exception(nameof(GlobalSession) + \" is Zero!\");\n        }\n\n        public static void DestroyGlobalSession()\n        {\n            lock (_Sync)\n            {\n                if (GlobalSession != IntPtr.Zero)\n                {","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/Orbmu2k/nvidiaProfileInspector/blob/2f50c388b3a4d661cade66b32746bec096d1eee1/nvidiaProfileInspector/Common/DrsSessionScope.cs#L21-L57","documentation":"NvapiException wrapping a non-NVAPI_OK status from DRS_LoadSettings. It fires inside the global DRS session bootstrap in DrsSessionScope: after DRS_CreateSession succeeds, the driver-settings store is loaded so the session reflects current on-disk settings; if the driver query fails (driver not installed, NVIDIA driver API unavailable, or the settings store could not be read), the status is wrapped and thrown, aborting the session before any caller action runs.","triggerScenarios":"After the global session is created in DrsSession, nvw.Instance.DRS_LoadSettings(GlobalSession) returns non-NVAPI_OK, raising this at DrsSessionScope.cs:39. Only occurs when preventLoadSettings is false (the default global path).","commonSituations":"Corrupted or locked driver settings store (nvdrsdb); driver update in progress or just replaced driver files; restricted user permissions on the driver settings store; rare transient driver API failure.","solutions":["Reboot or restart the display driver to release locks on the settings store","Reinstall/update the NVIDIA driver to rebuild the settings database","Run the app elevated to rule out permission issues on the driver store","Retry the operation — transient failures can occur during driver updates","Catch NvapiException and log the status to distinguish NVAPI_ERROR from NVAPI_EXECUTABLE etc."],"exampleFix":"// before\nDrsSession(hSession => SaveSettings(hSession));\n// after\ntry { DrsSession(hSession => SaveSettings(hSession)); }\ncatch (NvapiException ex) when (ex.Status == NvAPI_Status.NVAPI_ERROR)\n{\n    RetryAfterDelay(() => DrsSession(hSession => SaveSettings(hSession)));\n}","handlingStrategy":"retry","validationCode":"static bool DriverStoreLikelyReady() =>\n    Process.GetProcessesByName(\"nvxdsync\").Length >= 0 && !IsDriverInstalling(); // plus admin check if needed","typeGuard":null,"tryCatchPattern":"try\n{\n    DrsSession(h => SaveSettings(h));\n}\ncatch (NvapiException ex) when (ex.Message == \"DRS_LoadSettings\")\n{\n    await Task.Delay(1000);\n    DrsSession(h => SaveSettings(h)); // single retry\n}","preventionTips":["Avoid running DRS writes during driver installs/updates","Close NVIDIA Control Panel before bulk operations","Retry once with backoff for transient load failures","Run elevated when permissions on the driver store are restricted"],"tags":["nvapi","drs","session","driver-settings"],"backgroundTag":"api-error-response","analyzedSha":"2f50c388b3a4d661cade66b32746bec096d1eee1","analyzedAt":"2026-09-15T05:23:52.218Z","contentChangedAt":"2026-09-15T05:23:52.218Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}