Orbmu2k/nvidiaProfileInspector · error · NvapiException
DRS_GetProfileInfo
Error message
DRS_GetProfileInfo
What it means
NvapiException thrown when DRS_GetProfileInfo fails to fill an NVDRS_PROFILE struct for an existing profile handle. The library initializes tmpProfile with the correct NVDRS_PROFILE_VER before the call, so failures indicate an invalid session or profile handle, a struct version mismatch with the installed driver, or a generic driver error while reading the profile store.
Solutions
- Re-fetch the profile handle inside the same DrsSessionScope instead of caching hProfile across scopes.
- Check ex.Status: NVAPI_INVALID_ARGUMENT usually means NVDRS_PROFILE version mismatch - update the NVAPI wrapper/driver.
- Verify hSession and hProfile come from the same DRS_CreateSession session.
- Update the NVIDIA driver or the application's NVAPI definitions so struct versions agree.
- If the profile was deleted concurrently, re-enumerate profiles (EnumProfileHandles) and retry.
Example fix
// before
var info = service.GetProfileInfo(hSession, cachedHandle); // stale handle
// after
var handle = service.GetProfileHandle(hSession, profileName);
if (handle != IntPtr.Zero)
{
var info = service.GetProfileInfo(hSession, handle);
} Defensive patterns
Strategy: try-catch
Validate before calling
if (hProfile == IntPtr.Zero || hSession == IntPtr.Zero)
throw new ArgumentException("Session and profile handles must be non-zero"); Type guard
static bool HasValidHandles(IntPtr hSession, IntPtr hProfile) => hSession != IntPtr.Zero && hProfile != IntPtr.Zero;
Try / catch
try { info = GetProfileInfo(hSession, hProfile); }
catch (NvapiException ex) when (ex.Status == NvAPI_Status.NVAPI_INVALID_ARGUMENT)
{
// struct version mismatch or stale handle: re-resolve handle inside current scope
var fresh = GetProfileHandle(hSession, profileName);
if (fresh != IntPtr.Zero) info = GetProfileInfo(hSession, fresh);
} Prevention
- Never cache profile handles across DrsSessionScope lifetimes.
- Always set the struct version (NVDRS_PROFILE_VER) - the library does this, so prefer its API.
- Use handles and sessions from the same DRS_CreateSession call.
- After driver updates, re-enumerate handles instead of reusing old ones.
- Catch and inspect NvapiException.Status rather than assuming the handle was bad.
When it happens
Trigger: Calling GetProfileInfo with a stale hProfile (profile deleted or session destroyed), a handle from a different DRS session than hSession, a driver whose expected NVDRS_PROFILE version differs from the compiled-in NVDRS_PROFILE_VER (NVAPI_INVALID_ARGUMENT), or a corrupted driver settings store.
Common situations: Holding profile handles across DrsSessionScope boundaries (e.g. after MitigateNvapiAlreadyInUseBug or enumeration), driver upgrade between enumeration and info read, running against an old driver after updating the app, or profiles deleted concurrently by NVIDIA Control Panel.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- DRS_FindProfileByName
- DRS_CreateProfile
- DRS_SetSetting
- NvapiAddApplicationException(appName)
- DRS_CreateSession
AI-assisted analysis of Orbmu2k/nvidiaProfileInspector@2f50c388b3 (2026-09-15).
Data as JSON: /api/errors/36ca8fa983236d31.
Report an issue: GitHub.
Appendix: source
Thrown at nvidiaProfileInspector/Common/DrsSettingsServiceBase.cs:112
profileName = profileName,
};
var nvRes = nvw.Instance.DRS_CreateProfile(hSession, ref newProfile, ref hProfile);
if (nvRes != NvAPI_Status.NVAPI_OK)
throw new NvapiException("DRS_CreateProfile", nvRes);
return hProfile;
}
protected NVDRS_PROFILE GetProfileInfo(IntPtr hSession, IntPtr hProfile)
{
var tmpProfile = new NVDRS_PROFILE();
tmpProfile.version = nvw.NVDRS_PROFILE_VER;
var gpRes = nvw.Instance.DRS_GetProfileInfo(hSession, hProfile, ref tmpProfile);
if (gpRes != NvAPI_Status.NVAPI_OK)
throw new NvapiException("DRS_GetProfileInfo", gpRes);
return tmpProfile;
}
protected void StoreSetting(IntPtr hSession, IntPtr hProfile, NVDRS_SETTING newSetting)
{
var ssRes = nvw.Instance.DRS_SetSetting(hSession, hProfile, ref newSetting);
if (ssRes != NvAPI_Status.NVAPI_OK)
throw new NvapiException("DRS_SetSetting", ssRes);
}
protected void StoreDwordValue(IntPtr hSession, IntPtr hProfile, uint settingId, uint dwordValue)
{
var newSetting = new NVDRS_SETTING()
{
version = nvw.NVDRS_SETTING_VER,
settingId = settingId,
settingType = NVDRS_SETTING_TYPE.NVDRS_DWORD_TYPE,View on GitHub (pinned to 2f50c388b3)