Orbmu2k/nvidiaProfileInspector · error · ApplicationException

NVAPI Bug mitigation failed to restore application

Error message

NVAPI Bug mitigation failed to restore application '{appToRestore.appName}' in profile '{profile.profileName}'

What it means

ApplicationException thrown when the second half of MitigateNvapiAlreadyInUseBug fails: after re-adding the app to the current profile, the code fails to restore it in 'otherProfile' (the profile that previously held it). This leaves the app registered in the current profile but missing from its original profile. The message includes the app name and the resolved profile name.

Solutions

  1. Verify otherProfile is still valid (DRS_GetProfileInfo) before restoring; re-locate the profile by name if it was recreated.
  2. Manually re-add the application to the original profile afterwards, since the current-profile add already succeeded.
  3. Retry the restore step; transient driver failures are common here.
  4. Update GPU drivers to a version where the already-in-use bug is fixed to avoid entering mitigation at all.

Example fix

// before
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}'");
}
// after
var resOtherProfile = nvw.Instance.DRS_CreateApplication(hSession, otherProfile, ref appToRestore);
if (resOtherProfile == NvAPI_Status.NVAPI_EXECUTABLE_ALREADY_ON_PROFILE)
    return true;
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}'");
}
Defensive patterns

Strategy: fallback

Validate before calling

// confirm the other profile still exists before restore
var otherInfo = GetProfileInfo(hSession, otherProfile);

Try / catch

try { AddApplication(hSession, hProfile, appName, folder); }
catch (ApplicationException ex) when (ex.Message.Contains("failed to restore"))
{ // app was added to current profile but not restored; re-add manually to the original profile
  log.Warn(ex.Message); }

Prevention

When it happens

Trigger: DRS_CreateApplication(hSession, otherProfile, ref appToRestore) returns non-OK during the mitigation restore step — invalid otherProfile handle (e.g. the original profile was deleted), the app got re-registered elsewhere concurrently, or a driver-side registration failure.

Common situations: The original profile was deleted or renamed between capturing otherProfile and restoring; concurrent tools modifying profiles; driver bug recurrence during restore; session invalidated mid-mitigation.

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/98378800e9693332. Report an issue: GitHub.

Appendix: source

Thrown at nvidiaProfileInspector/Common/DrsSettingsServiceBase.cs:326

                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);
        }

        protected List<IntPtr> EnumProfileHandles(IntPtr hSession)
        {
            var profileHandles = new List<IntPtr>();
            var hProfile = IntPtr.Zero;
            uint index = 0;

View on GitHub (pinned to 2f50c388b3)