Orbmu2k/nvidiaProfileInspector · error · NvapiAddApplicationException

NvapiAddApplicationException(appName)

Error message

NvapiAddApplicationException(appName)

What it means

NvapiAddApplicationException wraps any NvapiException raised while trying to register an imported executable against a profile via DRS_CreateApplication. The driver rejected the DRS_CreateApplication call, so the import of this profile's executable list failed and the original driver status code is discarded, leaving only the failing application name.

Solutions

  1. Check that the target profile handle is valid and the session was created/loaded successfully before import
  2. Verify the failing appName string (shown in the exception) for invalid characters, empty value, or a duplicate already registered on the profile
  3. Remove or correct the offending executable entry in the source .nip file and re-run the import
  4. Update the NVIDIA display driver / nvw wrapper if DRS_CreateApplication persistently fails on valid input
  5. Catch NvapiAddApplicationException around ImportProfiles to surface which application failed instead of aborting the whole import

Example fix

// before
AddImportApplication(hSession, hProfile, importProfile, appName);
// after
try { AddImportApplication(hSession, hProfile, importProfile, appName); }
catch (NvapiAddApplicationException ex)
{
    Logger.Warn($"Import: could not add application '{ex.AppName}', skipping");
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (string.IsNullOrWhiteSpace(appName)) throw new ArgumentException("Executable name required");
if (profile.Executeables.GroupBy(a => a, StringComparer.OrdinalIgnoreCase).Any(g => g.Count() > 1))
    throw new InvalidOperationException("Duplicate executables in import file");

Type guard

static bool IsValidExecutableName(string name) =>
    !string.IsNullOrWhiteSpace(name) && name.IndexOfAny(Path.GetInvalidFileNameChars()) < 0;

Try / catch

try
{
    importService.ImportProfiles(path, overwrite);
}
catch (NvapiAddApplicationException ex)
{
    Logger.Warn($"Import failed on application '{ex.AppName}'");
}
catch (NvapiException ex)
{
    Logger.Error($"Driver API failure during import: {ex.Status}");
}

Prevention

When it happens

Trigger: ImportProfiles calls UpdateApplications, which iterates importProfile.Executeables and calls AddImportApplication for each app not already set; if the underlying AddApplication (DRS_CreateApplication) returns any non-OK status, the NvapiException is caught and rethrown as NvapiAddApplicationException(appName) at DrsImportService.cs:443.

Common situations: Importing a .nip file whose executable names are stale or duplicate against an existing profile; driver API state issues (e.g. session not loaded, invalid profile handle); exe names with characters or paths the driver API refuses; importing the same profile twice with overwrite semantics that race with existing applications.

Related errors


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

Appendix: source

Thrown at nvidiaProfileInspector/Common/DrsImportService.cs:443

            foreach (var app in apps)
            {
                if (ExistsImportApp(app.appName, importProfile) && !alreadySet.Contains(app.appName))
                    alreadySet.Add(app.appName);
                else
                    nvw.Instance.DRS_DeleteApplication(hSession, hProfile, new StringBuilder(app.appName));
            }

            foreach (string appName in importProfile.Executeables)
            {
                if (!alreadySet.Contains(appName))
                {
                    try
                    {
                        AddImportApplication(hSession, hProfile, importProfile, appName);
                    }
                    catch (NvapiException)
                    {
                        throw new NvapiAddApplicationException(appName);
                    }
                }
            }
        }

        // Adds an imported executable, restoring its "find file" (fileInFolder) when the
        // profile carried one for that executable.
        private void AddImportApplication(IntPtr hSession, IntPtr hProfile, Profile importProfile, string appName)
        {
            var findFile = importProfile.ExecutableFindFiles?
                .FirstOrDefault(x => string.Equals(x.Executable, appName, StringComparison.InvariantCultureIgnoreCase))
                ?.FindFile;

            if (!string.IsNullOrEmpty(findFile))
                AddApplication(hSession, hProfile, appName, findFile);
            else
                AddApplication(hSession, hProfile, appName);
        }

View on GitHub (pinned to 2f50c388b3)