Orbmu2k/nvidiaProfileInspector · error · ApplicationException

NVAPI Bug mitigation failed to add application

Error message

NVAPI Bug mitigation failed to add application '{pApplication.appName}' in current profile

What it means

ApplicationException thrown inside MitigateNvapiAlreadyInUseBug when the workaround's final DRS_CreateApplication call (re-adding the application to the current profile) fails. The mitigation moves the app out of a conflicting profile and back; if the 'restore into current profile' step fails, this error surfaces. It wraps no NvAPI status — only the fact that the bug workaround could not complete.

Solutions

  1. Retry the whole AddApplication operation once; mitigation failures are often transient driver-state issues.
  2. Check whether the app exists in the current profile already (DRS_FindApplicationByName) and treat that as success.
  3. Delete the app from all conflicting profiles manually via the NVIDIA control panel or DRS_DeleteApplicationEx, then re-add.
  4. Update GPU drivers — the already-in-use bug is driver-version specific.

Example fix

// before
var resCurrentProfile = nvw.Instance.DRS_CreateApplication(hSession, hProfile, ref pApplication);
if (resCurrentProfile != NvAPI_Status.NVAPI_OK)
    throw new ApplicationException($"NVAPI Bug mitigation failed to add application '{pApplication.appName}' in current profile");
// after
var resCurrentProfile = nvw.Instance.DRS_CreateApplication(hSession, hProfile, ref pApplication);
if (resCurrentProfile == NvAPI_Status.NVAPI_EXECUTABLE_ALREADY_ON_PROFILE)
    return true; // already present, mitigation effectively done
if (resCurrentProfile != NvAPI_Status.NVAPI_OK)
    throw new ApplicationException($"NVAPI Bug mitigation failed to add application '{pApplication.appName}' in current profile");
Defensive patterns

Strategy: retry

Validate before calling

// verify current profile still exists before relying on mitigation
var info = GetProfileInfo(hSession, hProfile); // throws if profile gone

Try / catch

try { AddApplication(hSession, hProfile, appName, folder); }
catch (ApplicationException ex) when (ex.Message.Contains("Bug mitigation failed"))
{ /* inspect profile state, retry once or guide user to clean the profile manually */ }

Prevention

When it happens

Trigger: NVAPI_EXECUTABLE_ALREADY_IN_USE triggered the mitigation; the app is not version 1 (so mitigation proceeds); then DRS_CreateApplication(hSession, hProfile, ref pApplication) returns non-OK when re-adding the app to the current profile.

Common situations: Driver bug where an app registered in '_Global' or another profile blocks re-registration; transient NVAPI failures during mitigation; profile deleted mid-mitigation; corrupted settings store.

Understand the failure class

Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.

Related errors


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

Appendix: source

Thrown at nvidiaProfileInspector/Common/DrsSettingsServiceBase.cs:320

            var otherApps = GetProfileApplications(hSession, otherProfile);
            
            NVDRS_APPLICATION_V4 appToRestore = new NVDRS_APPLICATION_V4() { version = 1 };

            foreach (var app in otherApps)
            {
                if (app.appName.Equals(exeOnly, StringComparison.InvariantCultureIgnoreCase))
                {
                    DeleteApplication(hSession, otherProfile, app);
                    appToRestore = app;
                    break;
                }
            }

            if (appToRestore.version == 1) return false;

            var resCurrentProfile = nvw.Instance.DRS_CreateApplication(hSession, hProfile, ref pApplication);
            if (resCurrentProfile != NvAPI_Status.NVAPI_OK)
                throw new ApplicationException($"NVAPI Bug mitigation failed to add application '{pApplication.appName}' in current profile");

            var resOtherProfile = nvw.Instance.DRS_CreateApplication(hSession, otherProfile, ref appToRestore);
            if (resOtherProfile != NvAPI_Status.NVAPI_OK)
            {
                var profile = GetProfileInfo(hSession, otherProfile);
                throw new ApplicationException($"NVAPI Bug mitigation failed to restore application '{appToRestore.appName}' in profile '{profile.profileName}'");
            }

            return true;
        }


        protected void DeleteApplication(IntPtr hSession, IntPtr hProfile, NVDRS_APPLICATION_V4 application)
        {
            var caRes = nvw.Instance.DRS_DeleteApplicationEx(hSession, hProfile, ref application);
            if (caRes != NvAPI_Status.NVAPI_OK)
                throw new NvapiException("DRS_DeleteApplication", caRes);
        }

View on GitHub (pinned to 2f50c388b3)