Orbmu2k/nvidiaProfileInspector · error · NvapiException
DRS_DeleteApplication
Error message
DRS_DeleteApplication
What it means
NvapiException thrown by DeleteApplication when DRS_DeleteApplicationEx returns a non-OK status. It means the driver refused to remove the executable registration from the profile. The wrapped NvAPI_Status gives the exact reason (app not found, invalid handle, etc.).
Solutions
- Check the wrapped NvAPI_Status; treat 'not found' statuses as already-deleted success cases.
- Ensure the application struct was obtained via DRS_FindApplicationByName/enum from the SAME profile handle you pass to DeleteApplication.
- Verify the session is still open and the profile exists before deleting.
- Retry after re-fetching the application struct if the driver state changed concurrently.
Example fix
// before
var caRes = nvw.Instance.DRS_DeleteApplicationEx(hSession, hProfile, ref application);
if (caRes != NvAPI_Status.NVAPI_OK)
throw new NvapiException("DRS_DeleteApplication", caRes);
// after
var caRes = nvw.Instance.DRS_DeleteApplicationEx(hSession, hProfile, ref application);
if (caRes == NvAPI_Status.NVAPI_EXECUTABLE_NOT_FOUND)
return; // already gone
if (caRes != NvAPI_Status.NVAPI_OK)
throw new NvapiException("DRS_DeleteApplication", caRes); Defensive patterns
Strategy: try-catch
Validate before calling
// ensure the app struct came from this profile var found = FindApplication(hSession, hProfile, application.appName); if (found == null) return; // nothing to delete
Try / catch
try { DeleteApplication(hSession, hProfile, app); }
catch (NvapiException ex) when (ex.Status == NvAPI_Status.NVAPI_EXECUTABLE_NOT_FOUND)
{ /* already removed - treat as success */ }
catch (NvapiException ex)
{ log.Error($"DRS_DeleteApplicationEx failed: {ex.Status}"); throw; } Prevention
- Only delete application structs obtained from the same profile handle.
- Re-fetch the app struct right before deleting to avoid stale data.
- Treat not-found statuses as idempotent success in callers.
- Keep the DRS session open across find-then-delete sequences.
When it happens
Trigger: DeleteApplication calls DRS_DeleteApplicationEx(hSession, hProfile, ref application) and the driver returns anything other than NVAPI_OK — application not registered in that profile, stale application struct/handle, invalid session, or internal NVAPI error.
Common situations: Deleting an app that was already removed (concurrent modification); passing an NVDRS_APPLICATION_V4 obtained from a different profile; session destroyed before the delete; the app is a pre-defined driver entry that cannot be removed.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
AI-assisted analysis of Orbmu2k/nvidiaProfileInspector@2f50c388b3 (2026-09-15).
Data as JSON: /api/errors/ebcc4b3ebbad0663.
Report an issue: GitHub.
Appendix: source
Thrown at nvidiaProfileInspector/Common/DrsSettingsServiceBase.cs:337
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;
NvAPI_Status nvRes;
do
{
nvRes = nvw.Instance.DRS_EnumProfiles(hSession, index, ref hProfile);
if (nvRes == NvAPI_Status.NVAPI_OK)
{
profileHandles.Add(hProfile);
}
index++;View on GitHub (pinned to 2f50c388b3)