Orbmu2k/nvidiaProfileInspector · error · NvapiException

DRS_LoadSettingsFromFileEx

Error message

DRS_LoadSettingsFromFileEx

What it means

NvapiException wrapping a non-OK status from DRS_LoadSettingsFromFileEx, which imports a previously exported .nvpi/nvidia settings file into the current DRS session. Thrown in LoadSettingsFileEx when the driver rejects the load — typically a missing file, unsupported format/version, or invalid session.

Solutions

  1. Check File.Exists on the filename before calling and surface a clear file error instead
  2. Confirm the file was exported by a compatible version of the tool/driver
  3. Catch the NvapiException, log its Status, and notify the user the import failed without corrupting current settings
  4. Retry with a freshly created DRS session if the handle was stale

Example fix

// before
LoadSettingsFileEx(hSession, filename);
// after
if (!File.Exists(filename)) throw new FileNotFoundException("Settings file not found", filename);
try { LoadSettingsFileEx(hSession, filename); }
catch (NvapiException ex) { Log.Error($"Import failed: {ex.Status}"); throw; }
Defensive patterns

Strategy: validation

Validate before calling

if (string.IsNullOrWhiteSpace(filename)) throw new ArgumentException("Filename required");
if (!File.Exists(filename)) throw new FileNotFoundException("Settings file not found", filename);

Try / catch

try { LoadSettingsFileEx(hSession, filename); }
catch (NvapiException ex) { ShowError($"Import failed ({ex.Status}). The file may be from an incompatible version."); }

Prevention

When it happens

Trigger: Importing a settings file that does not exist or is locked; the file was exported by an incompatible driver/Inspector version; filename encoding issues in the StringBuilder marshaling; hSession invalid at call time.

Common situations: Users restoring a .npi backup exported by a newer NVIDIA App or different Inspector version; file moved/renamed after being selected in a stale UI state; restoring across driver major versions where setting IDs changed.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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

Appendix: source

Thrown at nvidiaProfileInspector/Common/DrsSettingsServiceBase.cs:433

            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)