{"record":{"id":"7997ab7baa091845","repo":"Orbmu2k/nvidiaProfileInspector","slug":"drs-loadsettingsfromfileex","errorCode":null,"errorMessage":"DRS_LoadSettingsFromFileEx","messagePattern":"DRS_LoadSettingsFromFileEx","errorType":"exception","errorClass":"NvapiException","httpStatus":null,"severity":"error","filePath":"nvidiaProfileInspector/Common/DrsSettingsServiceBase.cs","lineNumber":433,"sourceCode":"\n            if (res != NvAPI_Status.NVAPI_OK)\n                throw new NvapiException(\"DRS_FindApplicationByName\", res);\n\n            return hProfile;\n        }\n\n        protected void SaveSettings(IntPtr hSession)\n        {\n            var nvRes = nvw.Instance.DRS_SaveSettings(hSession);\n            if (nvRes != NvAPI_Status.NVAPI_OK)\n                throw new NvapiException(\"DRS_SaveSettings\", nvRes);\n        }\n\n        protected void LoadSettingsFileEx(IntPtr hSession, string filename)\n        {\n            var nvRes = nvw.Instance.DRS_LoadSettingsFromFileEx(hSession, new StringBuilder(filename));\n            if (nvRes != NvAPI_Status.NVAPI_OK)\n                throw new NvapiException(\"DRS_LoadSettingsFromFileEx\", nvRes);\n        }\n\n        protected void SaveSettingsFileEx(IntPtr hSession, string filename)\n        {\n            var nvRes = nvw.Instance.DRS_SaveSettingsToFileEx(hSession, new StringBuilder(filename));\n            if (nvRes != NvAPI_Status.NVAPI_OK)\n                throw new NvapiException(\"DRS_SaveSettingsToFileEx\", nvRes);\n        }\n\n    }\n\n}\n\n","sourceCodeStart":415,"sourceCodeEnd":447,"githubUrl":"https://github.com/Orbmu2k/nvidiaProfileInspector/blob/2f50c388b3a4d661cade66b32746bec096d1eee1/nvidiaProfileInspector/Common/DrsSettingsServiceBase.cs#L415-L447","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check File.Exists on the filename before calling and surface a clear file error instead","Confirm the file was exported by a compatible version of the tool/driver","Catch the NvapiException, log its Status, and notify the user the import failed without corrupting current settings","Retry with a freshly created DRS session if the handle was stale"],"exampleFix":"// before\nLoadSettingsFileEx(hSession, filename);\n// after\nif (!File.Exists(filename)) throw new FileNotFoundException(\"Settings file not found\", filename);\ntry { LoadSettingsFileEx(hSession, filename); }\ncatch (NvapiException ex) { Log.Error($\"Import failed: {ex.Status}\"); throw; }","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(filename)) throw new ArgumentException(\"Filename required\");\nif (!File.Exists(filename)) throw new FileNotFoundException(\"Settings file not found\", filename);","typeGuard":null,"tryCatchPattern":"try { LoadSettingsFileEx(hSession, filename); }\ncatch (NvapiException ex) { ShowError($\"Import failed ({ex.Status}). The file may be from an incompatible version.\"); }","preventionTips":["Check File.Exists and file readability before import","Export and import with the same tool/driver version family","Validate the file extension (.npi) before passing it to NVAPI","Keep a live, valid DRS session during import"],"tags":["nvapi","driver-settings","file-import"],"backgroundTag":"file-not-found","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"}