Orbmu2k/nvidiaProfileInspector · error · NvapiException
DRS_EnumProfiles
Error message
DRS_EnumProfiles
What it means
NvapiException thrown by EnumProfileHandles when the profile enumeration loop terminates with any status other than NVAPI_OK or the expected NVAPI_END_ENUMERATION. The do/while loop enumerates profiles until the driver signals completion; any other terminating status (invalid session, internal error) is thrown. It indicates enumeration failed mid-way rather than completing normally.
Solutions
- Check the wrapped NvAPI_Status to distinguish invalid-session from internal-error cases.
- Re-create the DRS session via DRS_CreateSession and ensure it stays open for the whole enumeration.
- Close other NVIDIA tools that may lock the settings store and retry.
- Update or cleanly reinstall the GPU driver if corruption is suspected.
Example fix
// before
if (nvRes != NvAPI_Status.NVAPI_END_ENUMERATION)
throw new NvapiException("DRS_EnumProfiles", nvRes);
// after
if (nvRes != NvAPI_Status.NVAPI_END_ENUMERATION)
{
if (nvRes == NvAPI_Status.NVAPI_HANDLE_INVALIDATED)
throw new InvalidOperationException("DRS session was invalidated during profile enumeration");
throw new NvapiException("DRS_EnumProfiles", nvRes);
} Defensive patterns
Strategy: try-catch
Validate before calling
if (hSession == IntPtr.Zero)
throw new InvalidOperationException("DRS session not created"); Try / catch
try { var handles = EnumProfileHandles(hSession); }
catch (NvapiException ex)
{ log.Error($"DRS_EnumProfiles ended with {ex.Status}"); /* recreate session and retry */ } Prevention
- Keep the DRS session open for the entire enumeration loop.
- Avoid destroying/recreating the session concurrently with enumeration.
- Close other NVIDIA utilities that may lock the settings store.
- Update the driver if enumeration fails persistently.
When it happens
Trigger: The DRS_EnumProfiles loop ends with a status that is neither NVAPI_OK (continue) nor NVAPI_END_ENUMERATION (done) — typically NVAPI_INVALID_ARGUMENT from a bad hSession, NVAPI_HANDLE_INVALIDATED, or an internal NVAPI error mid-enumeration.
Common situations: Calling enumeration after DRS_DestroySession; driver settings store locked by another process (e.g. NVIDIA Control Panel); driver reinstall/update while enumerating; corrupted driver profile database.
Related errors
- DRS_GetSetting
- NvapiAddApplicationException(appName)
- DRS_CreateSession
- DRS_LoadSettings
- DRS_DestroySession
AI-assisted analysis of Orbmu2k/nvidiaProfileInspector@2f50c388b3 (2026-09-15).
Data as JSON: /api/errors/f384d6c0789a52d0.
Report an issue: GitHub.
Appendix: source
Thrown at nvidiaProfileInspector/Common/DrsSettingsServiceBase.cs:360
var profileHandles = new List<IntPtr>();
var hProfile = IntPtr.Zero;
uint index = 0;
NvAPI_Status nvRes;
do
{
nvRes = nvw.Instance.DRS_EnumProfiles(hSession, index, ref hProfile);
if (nvRes == NvAPI_Status.NVAPI_OK)
{
profileHandles.Add(hProfile);
}
index++;
}
while (nvRes == NvAPI_Status.NVAPI_OK);
if (nvRes != NvAPI_Status.NVAPI_END_ENUMERATION)
throw new NvapiException("DRS_EnumProfiles", nvRes);
return profileHandles;
}
protected List<NVDRS_SETTING> GetProfileSettings(IntPtr hSession, IntPtr hProfile, uint expectedCount = 512)
{
uint settingCount = expectedCount > 0 ? expectedCount : 1;
var settings = new NVDRS_SETTING[settingCount];
settings[0].version = NvapiDrsWrapper.NVDRS_SETTING_VER;
var esRes = NvapiDrsWrapper.Instance.DRS_EnumSettings(hSession, hProfile, 0, ref settingCount, ref settings);
if (esRes == NvAPI_Status.NVAPI_END_ENUMERATION)
return new List<NVDRS_SETTING>();
if (esRes != NvAPI_Status.NVAPI_OK)
throw new NvapiException("DRS_EnumSettings", esRes);
View on GitHub (pinned to 2f50c388b3)