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

  1. Confirm an NVIDIA GPU and current driver are installed and nvapi.dll loads (check driver version)
  2. Ensure nvapi.Initialize() succeeded before any DRS call
  3. Reinstall/update the NVIDIA display driver
  4. Check that the process is not sandboxed in a way that blocks driver API access
  5. 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

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


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)