{"record":{"id":"b93f5f0a35d9c806","repo":"Orbmu2k/nvidiaProfileInspector","slug":"drs-restoreprofiledefaultsetting","errorCode":null,"errorMessage":"DRS_RestoreProfileDefaultSetting","messagePattern":"DRS_RestoreProfileDefaultSetting","errorType":"exception","errorClass":"NvapiException","httpStatus":null,"severity":"error","filePath":"nvidiaProfileInspector/Common/DrsSettingsService.cs","lineNumber":304,"sourceCode":"                }\r\n            });\r\n\r\n            removeFromModified = tmpRemoveFromModified;\r\n        }\r\n\r\n        public void ResetValue(string profileName, uint settingId, out bool removeFromModified)\r\n        {\r\n            var tmpRemoveFromModified = false;\r\n\r\n            DrsSession((hSession) =>\r\n            {\r\n                var hProfile = GetProfileHandle(hSession, profileName);\r\n\r\n                if (hProfile != IntPtr.Zero)\r\n                {\r\n                    var nvRes = nvw.Instance.DRS_RestoreProfileDefaultSetting(hSession, hProfile, settingId);\r\n                    if (nvRes != NvAPI_Status.NVAPI_OK)\r\n                        throw new NvapiException(\"DRS_RestoreProfileDefaultSetting\", nvRes);\r\n\r\n                    SaveSettings(hSession);\r\n\r\n                    var modifyCount = 0;\r\n                    var settings = GetProfileSettings(hSession, hProfile);\r\n\r\n                    foreach (var setting in settings)\r\n                    {\r\n                        if (setting.isCurrentPredefined == 0 && setting.settingLocation == NVDRS_SETTING_LOCATION.NVDRS_CURRENT_PROFILE_LOCATION)\r\n                        {\r\n                            modifyCount++;\r\n                        }\r\n                    }\r\n                    tmpRemoveFromModified = (modifyCount == 0);\r\n                }\r\n            });\r\n\r\n            removeFromModified = tmpRemoveFromModified;\r","sourceCodeStart":286,"sourceCodeEnd":322,"githubUrl":"https://github.com/Orbmu2k/nvidiaProfileInspector/blob/2f50c388b3a4d661cade66b32746bec096d1eee1/nvidiaProfileInspector/Common/DrsSettingsService.cs#L286-L322","documentation":"NvapiException wrapping a non-NVAPI_OK status from DRS_RestoreProfileDefaultSetting. It is raised by ResetValue when deleting a single setting override: within a DRS session the profile handle is looked up and, if it exists, the driver is asked to restore the factory default for the given settingId; any failure status from the call is wrapped and thrown, so the individual setting override remains in place.","triggerScenarios":"Thrown at nvidiaProfileInspector/Common/DrsSettingsService.cs:304 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check that the settingId is a valid, currently-set value on that profile before resetting.","Catch NvapiException in the UI layer and inform the user the reset failed, keeping the current value.","Reopen the DRS session and retry once, as transient session-state errors can occur.","If the profile handle is IntPtr.Zero, skip the driver call instead of proceeding."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}