Orbmu2k/nvidiaProfileInspector · critical · NvapiException
DRS_CreateSession
Error message
DRS_CreateSession
What it means
NvapiException("DRS_CreateSession", status) is thrown when the global DRS session cannot be created — the nvapi DRS_CreateSession call returned a status other than NVAPI_OK while initializing the shared GlobalSession. Without a session, no driver-settings operations can run.
Solutions
- Confirm an NVIDIA GPU and current driver are installed and nvapi.dll loads (check driver version)
- Ensure nvapi.Initialize() succeeded before any DRS call
- Reinstall/update the NVIDIA display driver
- Check that the process is not sandboxed in a way that blocks driver API access
- Wrap DrsSession usage to catch NvapiException and surface the raw status code for diagnosis
Example fix
// before
DrsSession(hSession => { /* ... */ });
// after
try { DrsSession(hSession => { /* ... */ }); }
catch (NvapiException ex)
{
if (!NvapiAvailable()) throw new FriendlyException("NVIDIA driver settings are unavailable.", ex);
throw;
} Defensive patterns
Strategy: try-catch
Validate before calling
static bool IsNvidiaDriverAvailable()
{
try { nvw.Instance.Initialize(); return true; }
catch { return false; }
} Type guard
static bool CanUseDrs() => Environment.OSVersion.Platform == PlatformID.Win32NT && IsNvidiaDriverAvailable();
Try / catch
try
{
DrsSession(h => { /* work */ });
}
catch (NvapiException ex)
{
throw new DriverUnavailableException("NVIDIA driver settings unavailable", ex);
} Prevention
- Verify an NVIDIA GPU and matching driver are installed before launching DRS features
- Match process bitness to nvapi.dll (x64 vs x86)
- Call nvapi.Initialize once and check it succeeded before any DRS call
- Feature-detect at startup and disable DRS UI when the driver is absent
When it happens
Trigger: DrsSession's lazy global-session initialization calls nvw.Instance.DRS_CreateSession(ref GlobalSession); any non-NVAPI_OK result raises this at DrsSessionScope.cs:33. This runs on the first DRS operation in the process unless preventLoadSettings paths skip loading.
Common situations: NVIDIA driver not installed or nvapi.dll missing/incompatible; running on a system without an NVIDIA GPU; driver API initialization failure (Initialize earlier failed); corrupted driver install after an update.
Related errors
- DRS_LoadSettings
- NvapiAddApplicationException(appName)
- DRS_DestroySession
- DRS_DeleteProfile
- DRS_RestoreAllDefaults
AI-assisted analysis of Orbmu2k/nvidiaProfileInspector@2f50c388b3 (2026-09-15).
Data as JSON: /api/errors/d8c14cbb61557d77.
Report an issue: GitHub.
Appendix: source
Thrown at nvidiaProfileInspector/Common/DrsSessionScope.cs:33
public static T DrsSession<T>(Func<IntPtr, T> action, bool forceNonGlobalSession = false, bool preventLoadSettings = false)
{
lock (_Sync)
{
if (!HoldSession || forceNonGlobalSession)
return NonGlobalDrsSession<T>(action, preventLoadSettings);
if (GlobalSession == IntPtr.Zero)
{
#pragma warning disable CS0420
var csRes = nvw.Instance.DRS_CreateSession(ref GlobalSession);
#pragma warning restore CS0420
if (csRes != NvAPI_Status.NVAPI_OK)
throw new NvapiException("DRS_CreateSession", csRes);
if (!preventLoadSettings)
{
var nvRes = nvw.Instance.DRS_LoadSettings(GlobalSession);
if (nvRes != NvAPI_Status.NVAPI_OK)
throw new NvapiException("DRS_LoadSettings", nvRes);
}
}
}
if (GlobalSession != IntPtr.Zero)
{
return action(GlobalSession);
}
throw new Exception(nameof(GlobalSession) + " is Zero!");
}
View on GitHub (pinned to 2f50c388b3)