{"record":{"id":"c72337c05ed11221","repo":"Orbmu2k/nvidiaProfileInspector","slug":"drs-restoreprofiledefault","errorCode":null,"errorMessage":"DRS_RestoreProfileDefault","messagePattern":"DRS_RestoreProfileDefault","errorType":"exception","errorClass":"NvapiException","httpStatus":null,"severity":"error","filePath":"nvidiaProfileInspector/Common/DrsSettingsService.cs","lineNumber":262,"sourceCode":"                    throw new NvapiException(\"DRS_RestoreAllDefaults\", nvRes);\r\n\r\n                SaveSettings(hSession);\r\n            });\r\n        }\r\n\r\n        public void ResetProfile(string profileName, out bool removeFromModified)\r\n        {\r\n            bool tmpRemoveFromModified = false;\r\n            DrsSession((hSession) =>\r\n            {\r\n                var hProfile = GetProfileHandle(hSession, profileName);\r\n                var profile = GetProfileInfo(hSession, hProfile);\r\n\r\n                if (profile.isPredefined == 1)\r\n                {\r\n                    var nvRes = nvw.Instance.DRS_RestoreProfileDefault(hSession, hProfile);\r\n                    if (nvRes != NvAPI_Status.NVAPI_OK)\r\n                        throw new NvapiException(\"DRS_RestoreProfileDefault\", nvRes);\r\n\r\n                    SaveSettings(hSession);\r\n                    tmpRemoveFromModified = true;\r\n                }\r\n                else if (profile.numOfSettings > 0)\r\n                {\r\n                    int dropCount = 0;\r\n                    var settings = GetProfileSettings(hSession, hProfile);\r\n\r\n                    foreach (var setting in settings)\r\n                    {\r\n                        if (setting.settingLocation == NVDRS_SETTING_LOCATION.NVDRS_CURRENT_PROFILE_LOCATION)\r\n                        {\r\n                            if (nvw.Instance.DRS_DeleteProfileSetting(hSession, hProfile, setting.settingId) == NvAPI_Status.NVAPI_OK)\r\n                            {\r\n                                dropCount++;\r\n                            }\r\n                        }\r","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/Orbmu2k/nvidiaProfileInspector/blob/2f50c388b3a4d661cade66b32746bec096d1eee1/nvidiaProfileInspector/Common/DrsSettingsService.cs#L244-L280","documentation":"NvapiException wrapping a non-NVAPI_OK status from DRS_RestoreProfileDefault. It is raised by ResetProfile while resetting a profile inside a DRS session: GetProfileHandle/GetProfileInfo determined the profile is predefined (isPredefined == 1), so the code calls DRS_RestoreProfileDefault to restore the driver's factory version of that predefined profile; a failure status from the driver is wrapped and thrown, leaving the predefined profile unrestored.","triggerScenarios":"Thrown at nvidiaProfileInspector/Common/DrsSettingsService.cs:262 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the NVIDIA driver is installed and the profile name exists before calling ResetProfile.","Catch NvapiException around ResetProfile and surface the wrapped status to the caller instead of crashing.","Retry the reset in a fresh DRS session, since a stale shared session handle can return errors.","For non-predefined profiles, remove the profile rather than calling DRS_RestoreProfileDefault, which only applies to predefined ones."],"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"}