Orbmu2k/nvidiaProfileInspector · error · NvapiException

DRS_SaveSettings

Error message

DRS_SaveSettings

What it means

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.

Solutions

  1. Verify the session and profile handles are still valid before saving and re-open them if needed
  2. Retry the save once after a short delay (driver service may be momentarily busy)
  3. Check that the preceding DRS_SetSetting/DRS_DeleteProfileSetting calls returned NVAPI_OK
  4. Run under the same elevated account consistently; some store writes require elevation
  5. Re-create the session, re-apply changes, and save again if the first save fails
Defensive patterns

Strategy: retry

Validate before calling

if (hSession == IntPtr.Zero) throw new InvalidOperationException("DRS session is not open");

Try / catch

try { SaveSettings(hSession); }
catch (NvapiException ex) { await Task.Delay(500); SaveSettings(hSession); } // retry once after driver settles

Prevention

When it happens

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

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

Related errors


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

Appendix: source

Thrown at nvidiaProfileInspector/Common/DrsSettingsServiceBase.cs:426

        protected IntPtr FindApplicationByName(IntPtr hSession, string appName)
        {
            IntPtr hProfile = IntPtr.Zero;
            NVDRS_APPLICATION_V4 app = new NVDRS_APPLICATION_V4();
            app.version = NvapiDrsWrapper.NVDRS_APPLICATION_VER_V4;

            var res = NvapiDrsWrapper.Instance.DRS_FindApplicationByName(hSession, new StringBuilder(appName), ref hProfile, ref app);

            if (res != NvAPI_Status.NVAPI_OK)
                throw new NvapiException("DRS_FindApplicationByName", res);

            return hProfile;
        }

        protected void SaveSettings(IntPtr hSession)
        {
            var nvRes = nvw.Instance.DRS_SaveSettings(hSession);
            if (nvRes != NvAPI_Status.NVAPI_OK)
                throw new NvapiException("DRS_SaveSettings", nvRes);
        }

        protected void LoadSettingsFileEx(IntPtr hSession, string filename)
        {
            var nvRes = nvw.Instance.DRS_LoadSettingsFromFileEx(hSession, new StringBuilder(filename));
            if (nvRes != NvAPI_Status.NVAPI_OK)
                throw new NvapiException("DRS_LoadSettingsFromFileEx", nvRes);
        }

        protected void SaveSettingsFileEx(IntPtr hSession, string filename)
        {
            var nvRes = nvw.Instance.DRS_SaveSettingsToFileEx(hSession, new StringBuilder(filename));
            if (nvRes != NvAPI_Status.NVAPI_OK)
                throw new NvapiException("DRS_SaveSettingsToFileEx", nvRes);
        }

    }

View on GitHub (pinned to 2f50c388b3)