{"record":{"id":"8251f2fb15c4700b","repo":"Orbmu2k/nvidiaProfileInspector","slug":"drs-getsetting","errorCode":null,"errorMessage":"DRS_GetSetting","messagePattern":"DRS_GetSetting","errorType":"exception","errorClass":"NvapiException","httpStatus":null,"severity":"error","filePath":"nvidiaProfileInspector/Common/DrsSettingsServiceBase.cs","lineNumber":216,"sourceCode":"            var ssRes = nvw.Instance.DRS_SetSetting(hSession, hProfile, ref newSetting);\n            if (ssRes != NvAPI_Status.NVAPI_OK)\n                throw new NvapiException(\"DRS_SetSetting\", ssRes);\n\n        }\n\n        protected NVDRS_SETTING? ReadSetting(IntPtr hSession, IntPtr hProfile, uint settingId)\n        {\n            var newSetting = new NVDRS_SETTING()\n            {\n                version = nvw.NVDRS_SETTING_VER,\n            };\n\n            var ssRes = nvw.Instance.DRS_GetSetting(hSession, hProfile, settingId, ref newSetting);\n            if (ssRes == NvAPI_Status.NVAPI_SETTING_NOT_FOUND)\n                return null;\n\n            if (ssRes != NvAPI_Status.NVAPI_OK)\n                throw new NvapiException(\"DRS_GetSetting\", ssRes);\n\n            if (decrypter != null)\n            {\n                var profile = GetProfileInfo(hSession, hProfile);\n                decrypter.DecryptSettingIfNeeded(profile.profileName, ref newSetting);\n            }\n\n            return newSetting;\n        }\n\n        protected uint? ReadDwordValue(IntPtr hSession, IntPtr hProfile, uint settingId)\n        {\n            var newSetting = ReadSetting(hSession, hProfile, settingId);\n            if (newSetting == null)\n                return null;\n            return newSetting.Value.currentValue.dwordValue;\n        }\n","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/Orbmu2k/nvidiaProfileInspector/blob/2f50c388b3a4d661cade66b32746bec096d1eee1/nvidiaProfileInspector/Common/DrsSettingsServiceBase.cs#L198-L234","documentation":"NvapiException thrown by ReadSetting when DRS_GetSetting returns a non-OK status other than NVAPI_SETTING_NOT_FOUND (which is handled by returning null). It means the driver failed to read the setting for reasons other than it simply being absent. The wrapped NvAPI_Status identifies the driver-side failure.","triggerScenarios":"ReadSetting calls DRS_GetSetting(hSession, hProfile, settingId, ref newSetting); statuses other than NVAPI_OK and NVAPI_SETTING_NOT_FOUND — e.g. invalid session/profile handle or NVAPI internal error — trigger the throw.","commonSituations":"Querying with a stale or destroyed session handle; invalid settingId causing unexpected statuses; driver settings store corruption; driver not installed so NVAPI initialization failed upstream.","solutions":["Inspect the wrapped NvAPI_Status; treat NVAPI_SETTING_NOT_FOUND as a normal 'absent' case (the library already does).","Verify hSession/hProfile are valid and the session is still open before reading.","Re-create the session via DRS_CreateSession / reload the profile if handles may be stale.","Reinstall/update the GPU driver if statuses indicate store corruption."],"exampleFix":"// before\nvar ssRes = nvw.Instance.DRS_GetSetting(hSession, hProfile, settingId, ref newSetting);\nif (ssRes == NvAPI_Status.NVAPI_SETTING_NOT_FOUND)\n    return null;\nif (ssRes != NvAPI_Status.NVAPI_OK)\n    throw new NvapiException(\"DRS_GetSetting\", ssRes);\n// after\nvar ssRes = nvw.Instance.DRS_GetSetting(hSession, hProfile, settingId, ref newSetting);\nif (ssRes == NvAPI_Status.NVAPI_SETTING_NOT_FOUND || ssRes == NvAPI_Status.NVAPI_EXECUTABLE_NOT_FOUND)\n    return null;\nif (ssRes != NvAPI_Status.NVAPI_OK)\n    throw new NvapiException(\"DRS_GetSetting\", ssRes);","handlingStrategy":"try-catch","validationCode":"if (hSession == IntPtr.Zero || hProfile == IntPtr.Zero)\n    throw new InvalidOperationException(\"DRS handles not initialized\");","typeGuard":null,"tryCatchPattern":"try { var setting = ReadSetting(hSession, hProfile, settingId); }\ncatch (NvapiException ex) when (ex.Status == NvAPI_Status.NVAPI_SETTING_NOT_FOUND)\n{ setting = null; }\ncatch (NvapiException ex)\n{ log.Error($\"DRS_GetSetting failed: {ex.Status}\"); throw; }","preventionTips":["Treat NVAPI_SETTING_NOT_FOUND as a normal absent-setting result, not an error.","Validate session/profile handles before reading.","Keep the session alive across read calls.","Update drivers if read failures persist across setting ids."],"tags":["nvapi","driver-settings","read","gpu"],"backgroundTag":"record-not-found","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"}