Orbmu2k/nvidiaProfileInspector · error · NvapiException

DRS_DeleteProfile

Error message

DRS_DeleteProfile

What it means

NvapiException("DRS_DeleteProfile", status) is thrown when the driver API DRS_DeleteProfile call fails after the profile's applications were removed. The profile still exists on disk and the operation aborts before SaveSettings.

Solutions

  1. Re-fetch the profile list to confirm the profile still exists before deleting
  2. Check the profile is not a driver-protected built-in (only base profile should be, but verify the name)
  3. Close other applications using the driver settings store and retry
  4. Run elevated if the settings store is permission-restricted
  5. Catch NvapiException and log the status; refresh UI state since the profile may be partially modified

Example fix

// before
settingsService.DeleteProfile(profileName);
// after
try { settingsService.DeleteProfile(profileName); }
catch (NvapiException ex)
{
    Log.Error($"Failed to delete profile '{profileName}': {ex.Status}");
    RefreshProfileList();
}
Defensive patterns

Strategy: try-catch

Validate before calling

var profiles = settingsService.GetProfiles();
if (!profiles.Any(p => string.Equals(p.Name, profileName, StringComparison.OrdinalIgnoreCase)))
    return; // already gone — nothing to delete

Try / catch

try
{
    settingsService.DeleteProfile(profileName);
}
catch (NvapiException ex)
{
    Log.Error($"DeleteProfile '{profileName}' failed: {ex.Status}");
    RefreshProfileList();
}

Prevention

When it happens

Trigger: DeleteProfile resolves the profile handle, deletes each of its applications, then calls nvw.Instance.DRS_DeleteProfile(hSession, hProfile); a non-NVAPI_OK result throws at DrsSettingsService.cs:157 inside the NonGlobalDrsSession callback.

Common situations: Profile already deleted by another process (handle stale); driver refuses to delete a protected/built-in profile; driver settings store locked or corrupted; permission issues.

Related errors


AI-assisted analysis of Orbmu2k/nvidiaProfileInspector@2f50c388b3 (2026-09-15). Data as JSON: /api/errors/700cfd02a744941c. Report an issue: GitHub.

Appendix: source

Thrown at nvidiaProfileInspector/Common/DrsSettingsService.cs:157

                var baseProfileHandle = GetProfileHandle(hSession, null);
                if (hProfile == baseProfileHandle)
                {
                    throw new InvalidOperationException("Base profile cannot be deleted.");
                }


                if (hProfile != IntPtr.Zero)
                {
                    // Try removing applications from profile before deleting, prevents possible orphans
                    var applications = GetProfileApplications(hSession, hProfile);
                    foreach (var app in applications)
                    {
                        DeleteApplication(hSession, hProfile, app);
                    }

                    var nvRes = nvw.Instance.DRS_DeleteProfile(hSession, hProfile);
                    if (nvRes != NvAPI_Status.NVAPI_OK)
                        throw new NvapiException("DRS_DeleteProfile", nvRes);

                    SaveSettings(hSession);
                }
            });

        }

        public string GetProfileNameByExeName(string appName)
        {
            string profileName = string.Empty;

            DrsSession((hSession) =>
            {
                var hProfile = FindApplicationByName(hSession, appName);
                if (hProfile != IntPtr.Zero)
                {
                    var profile = GetProfileInfo(hSession, hProfile);

View on GitHub (pinned to 2f50c388b3)