{"record":{"id":"084d90fe9c7b5085","repo":"Orbmu2k/nvidiaProfileInspector","slug":"drs-savesettings","errorCode":null,"errorMessage":"DRS_SaveSettings","messagePattern":"DRS_SaveSettings","errorType":"exception","errorClass":"NvapiException","httpStatus":null,"severity":"error","filePath":"nvidiaProfileInspector/Common/DrsSettingsServiceBase.cs","lineNumber":426,"sourceCode":"        protected IntPtr FindApplicationByName(IntPtr hSession, string appName)\n        {\n            IntPtr hProfile = IntPtr.Zero;\n            NVDRS_APPLICATION_V4 app = new NVDRS_APPLICATION_V4();\n            app.version = NvapiDrsWrapper.NVDRS_APPLICATION_VER_V4;\n\n            var res = NvapiDrsWrapper.Instance.DRS_FindApplicationByName(hSession, new StringBuilder(appName), ref hProfile, ref app);\n\n            if (res != NvAPI_Status.NVAPI_OK)\n                throw new NvapiException(\"DRS_FindApplicationByName\", res);\n\n            return hProfile;\n        }\n\n        protected void SaveSettings(IntPtr hSession)\n        {\n            var nvRes = nvw.Instance.DRS_SaveSettings(hSession);\n            if (nvRes != NvAPI_Status.NVAPI_OK)\n                throw new NvapiException(\"DRS_SaveSettings\", nvRes);\n        }\n\n        protected void LoadSettingsFileEx(IntPtr hSession, string filename)\n        {\n            var nvRes = nvw.Instance.DRS_LoadSettingsFromFileEx(hSession, new StringBuilder(filename));\n            if (nvRes != NvAPI_Status.NVAPI_OK)\n                throw new NvapiException(\"DRS_LoadSettingsFromFileEx\", nvRes);\n        }\n\n        protected void SaveSettingsFileEx(IntPtr hSession, string filename)\n        {\n            var nvRes = nvw.Instance.DRS_SaveSettingsToFileEx(hSession, new StringBuilder(filename));\n            if (nvRes != NvAPI_Status.NVAPI_OK)\n                throw new NvapiException(\"DRS_SaveSettingsToFileEx\", nvRes);\n        }\n\n    }\n","sourceCodeStart":408,"sourceCodeEnd":444,"githubUrl":"https://github.com/Orbmu2k/nvidiaProfileInspector/blob/2f50c388b3a4d661cade66b32746bec096d1eee1/nvidiaProfileInspector/Common/DrsSettingsServiceBase.cs#L408-L444","documentation":"NvapiException wrapping a non-OK status from DRS_SaveSettings, which commits pending profile changes to the driver settings store. Thrown in SaveSettings after a modification batch (set/delete setting) when the driver refuses or fails the commit. Without a successful save, in-memory changes are lost when the session is destroyed.","triggerScenarios":"Calling DRS_SaveSettings on a destroyed or invalid hSession; a prior DRS_SetSetting in the batch left the session in a bad state; driver service busy or restarting; insufficient rights to write the driver settings store.","commonSituations":"Applying settings immediately after driver installation while the driver service is reloading; multiple processes holding DRS sessions writing concurrently; saving after the profile was deleted externally by NVIDIA App/GeForce Experience.","solutions":["Verify the session and profile handles are still valid before saving and re-open them if needed","Retry the save once after a short delay (driver service may be momentarily busy)","Check that the preceding DRS_SetSetting/DRS_DeleteProfileSetting calls returned NVAPI_OK","Run under the same elevated account consistently; some store writes require elevation","Re-create the session, re-apply changes, and save again if the first save fails"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if (hSession == IntPtr.Zero) throw new InvalidOperationException(\"DRS session is not open\");","typeGuard":null,"tryCatchPattern":"try { SaveSettings(hSession); }\ncatch (NvapiException ex) { await Task.Delay(500); SaveSettings(hSession); } // retry once after driver settles","preventionTips":["Verify every DRS_SetSetting returned NVAPI_OK before saving","Retry the save after a short delay; driver service may be busy","Recreate the session if handles were invalidated by a driver update","Keep write access to the driver settings store (consistent elevation)"],"tags":["nvapi","driver-settings","native-interop"],"backgroundTag":"database-write-failed","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"}