{"record":{"id":"5a6bd68eedb74f7a","repo":"Orbmu2k/nvidiaProfileInspector","slug":"nvapi-bug-mitigation-failed-to-add-application-papplication","errorCode":null,"errorMessage":"NVAPI Bug mitigation failed to add application '{pApplication.appName}' in current profile","messagePattern":"NVAPI Bug mitigation failed to add application '(.+?)' in current profile","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"nvidiaProfileInspector/Common/DrsSettingsServiceBase.cs","lineNumber":320,"sourceCode":"            var otherApps = GetProfileApplications(hSession, otherProfile);\n            \n            NVDRS_APPLICATION_V4 appToRestore = new NVDRS_APPLICATION_V4() { version = 1 };\n\n            foreach (var app in otherApps)\n            {\n                if (app.appName.Equals(exeOnly, StringComparison.InvariantCultureIgnoreCase))\n                {\n                    DeleteApplication(hSession, otherProfile, app);\n                    appToRestore = app;\n                    break;\n                }\n            }\n\n            if (appToRestore.version == 1) return false;\n\n            var resCurrentProfile = nvw.Instance.DRS_CreateApplication(hSession, hProfile, ref pApplication);\n            if (resCurrentProfile != NvAPI_Status.NVAPI_OK)\n                throw new ApplicationException($\"NVAPI Bug mitigation failed to add application '{pApplication.appName}' in current profile\");\n\n            var resOtherProfile = nvw.Instance.DRS_CreateApplication(hSession, otherProfile, ref appToRestore);\n            if (resOtherProfile != NvAPI_Status.NVAPI_OK)\n            {\n                var profile = GetProfileInfo(hSession, otherProfile);\n                throw new ApplicationException($\"NVAPI Bug mitigation failed to restore application '{appToRestore.appName}' in profile '{profile.profileName}'\");\n            }\n\n            return true;\n        }\n\n\n        protected void DeleteApplication(IntPtr hSession, IntPtr hProfile, NVDRS_APPLICATION_V4 application)\n        {\n            var caRes = nvw.Instance.DRS_DeleteApplicationEx(hSession, hProfile, ref application);\n            if (caRes != NvAPI_Status.NVAPI_OK)\n                throw new NvapiException(\"DRS_DeleteApplication\", caRes);\n        }","sourceCodeStart":302,"sourceCodeEnd":338,"githubUrl":"https://github.com/Orbmu2k/nvidiaProfileInspector/blob/2f50c388b3a4d661cade66b32746bec096d1eee1/nvidiaProfileInspector/Common/DrsSettingsServiceBase.cs#L302-L338","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Retry the whole AddApplication operation once; mitigation failures are often transient driver-state issues.","Check whether the app exists in the current profile already (DRS_FindApplicationByName) and treat that as success.","Delete the app from all conflicting profiles manually via the NVIDIA control panel or DRS_DeleteApplicationEx, then re-add.","Update GPU drivers — the already-in-use bug is driver-version specific."],"exampleFix":"// before\nvar resCurrentProfile = nvw.Instance.DRS_CreateApplication(hSession, hProfile, ref pApplication);\nif (resCurrentProfile != NvAPI_Status.NVAPI_OK)\n    throw new ApplicationException($\"NVAPI Bug mitigation failed to add application '{pApplication.appName}' in current profile\");\n// after\nvar resCurrentProfile = nvw.Instance.DRS_CreateApplication(hSession, hProfile, ref pApplication);\nif (resCurrentProfile == NvAPI_Status.NVAPI_EXECUTABLE_ALREADY_ON_PROFILE)\n    return true; // already present, mitigation effectively done\nif (resCurrentProfile != NvAPI_Status.NVAPI_OK)\n    throw new ApplicationException($\"NVAPI Bug mitigation failed to add application '{pApplication.appName}' in current profile\");","handlingStrategy":"retry","validationCode":"// verify current profile still exists before relying on mitigation\nvar info = GetProfileInfo(hSession, hProfile); // throws if profile gone","typeGuard":null,"tryCatchPattern":"try { AddApplication(hSession, hProfile, appName, folder); }\ncatch (ApplicationException ex) when (ex.Message.Contains(\"Bug mitigation failed\"))\n{ /* inspect profile state, retry once or guide user to clean the profile manually */ }","preventionTips":["Retry AddApplication once after a mitigation failure; driver state is often transient.","Check for the app's existing registration before triggering mitigation.","Keep GPU drivers updated to reduce NVAPI already-in-use bug occurrences.","Avoid concurrent profile modifications while mitigation runs."],"tags":["nvapi","driver-bug","workaround","profile"],"backgroundTag":"api-request-failed","analyzedSha":"2f50c388b3a4d661cade66b32746bec096d1eee1","analyzedAt":"2026-09-15T05:23:52.218Z","contentChangedAt":"2026-09-15T05:23:52.218Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}