Orbmu2k/nvidiaProfileInspector · error · NvapiException

DRS_GetSetting

Error message

DRS_GetSetting

What it means

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.

Solutions

  1. Inspect the wrapped NvAPI_Status; treat NVAPI_SETTING_NOT_FOUND as a normal 'absent' case (the library already does).
  2. Verify hSession/hProfile are valid and the session is still open before reading.
  3. Re-create the session via DRS_CreateSession / reload the profile if handles may be stale.
  4. Reinstall/update the GPU driver if statuses indicate store corruption.

Example fix

// before
var ssRes = nvw.Instance.DRS_GetSetting(hSession, hProfile, settingId, ref newSetting);
if (ssRes == NvAPI_Status.NVAPI_SETTING_NOT_FOUND)
    return null;
if (ssRes != NvAPI_Status.NVAPI_OK)
    throw new NvapiException("DRS_GetSetting", ssRes);
// after
var ssRes = nvw.Instance.DRS_GetSetting(hSession, hProfile, settingId, ref newSetting);
if (ssRes == NvAPI_Status.NVAPI_SETTING_NOT_FOUND || ssRes == NvAPI_Status.NVAPI_EXECUTABLE_NOT_FOUND)
    return null;
if (ssRes != NvAPI_Status.NVAPI_OK)
    throw new NvapiException("DRS_GetSetting", ssRes);
Defensive patterns

Strategy: try-catch

Validate before calling

if (hSession == IntPtr.Zero || hProfile == IntPtr.Zero)
    throw new InvalidOperationException("DRS handles not initialized");

Try / catch

try { var setting = ReadSetting(hSession, hProfile, settingId); }
catch (NvapiException ex) when (ex.Status == NvAPI_Status.NVAPI_SETTING_NOT_FOUND)
{ setting = null; }
catch (NvapiException ex)
{ log.Error($"DRS_GetSetting failed: {ex.Status}"); throw; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of Orbmu2k/nvidiaProfileInspector@2f50c388b3 (2026-09-15). Data as JSON: /api/errors/8251f2fb15c4700b. Report an issue: GitHub.

Appendix: source

Thrown at nvidiaProfileInspector/Common/DrsSettingsServiceBase.cs:216

            var ssRes = nvw.Instance.DRS_SetSetting(hSession, hProfile, ref newSetting);
            if (ssRes != NvAPI_Status.NVAPI_OK)
                throw new NvapiException("DRS_SetSetting", ssRes);

        }

        protected NVDRS_SETTING? ReadSetting(IntPtr hSession, IntPtr hProfile, uint settingId)
        {
            var newSetting = new NVDRS_SETTING()
            {
                version = nvw.NVDRS_SETTING_VER,
            };

            var ssRes = nvw.Instance.DRS_GetSetting(hSession, hProfile, settingId, ref newSetting);
            if (ssRes == NvAPI_Status.NVAPI_SETTING_NOT_FOUND)
                return null;

            if (ssRes != NvAPI_Status.NVAPI_OK)
                throw new NvapiException("DRS_GetSetting", ssRes);

            if (decrypter != null)
            {
                var profile = GetProfileInfo(hSession, hProfile);
                decrypter.DecryptSettingIfNeeded(profile.profileName, ref newSetting);
            }

            return newSetting;
        }

        protected uint? ReadDwordValue(IntPtr hSession, IntPtr hProfile, uint settingId)
        {
            var newSetting = ReadSetting(hSession, hProfile, settingId);
            if (newSetting == null)
                return null;
            return newSetting.Value.currentValue.dwordValue;
        }

View on GitHub (pinned to 2f50c388b3)