{"record":{"id":"0d75912690570c7c","repo":"Orbmu2k/nvidiaProfileInspector","slug":"nvapiaddapplicationexception-appname","errorCode":null,"errorMessage":"NvapiAddApplicationException(appName)","messagePattern":"NvapiAddApplicationException\\(appName\\)","errorType":"exception","errorClass":"NvapiAddApplicationException","httpStatus":null,"severity":"error","filePath":"nvidiaProfileInspector/Common/DrsImportService.cs","lineNumber":443,"sourceCode":"            foreach (var app in apps)\n            {\n                if (ExistsImportApp(app.appName, importProfile) && !alreadySet.Contains(app.appName))\n                    alreadySet.Add(app.appName);\n                else\n                    nvw.Instance.DRS_DeleteApplication(hSession, hProfile, new StringBuilder(app.appName));\n            }\n\n            foreach (string appName in importProfile.Executeables)\n            {\n                if (!alreadySet.Contains(appName))\n                {\n                    try\n                    {\n                        AddImportApplication(hSession, hProfile, importProfile, appName);\n                    }\n                    catch (NvapiException)\n                    {\n                        throw new NvapiAddApplicationException(appName);\n                    }\n                }\n            }\n        }\n\n        // Adds an imported executable, restoring its \"find file\" (fileInFolder) when the\n        // profile carried one for that executable.\n        private void AddImportApplication(IntPtr hSession, IntPtr hProfile, Profile importProfile, string appName)\n        {\n            var findFile = importProfile.ExecutableFindFiles?\n                .FirstOrDefault(x => string.Equals(x.Executable, appName, StringComparison.InvariantCultureIgnoreCase))\n                ?.FindFile;\n\n            if (!string.IsNullOrEmpty(findFile))\n                AddApplication(hSession, hProfile, appName, findFile);\n            else\n                AddApplication(hSession, hProfile, appName);\n        }","sourceCodeStart":425,"sourceCodeEnd":461,"githubUrl":"https://github.com/Orbmu2k/nvidiaProfileInspector/blob/2f50c388b3a4d661cade66b32746bec096d1eee1/nvidiaProfileInspector/Common/DrsImportService.cs#L425-L461","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check that the target profile handle is valid and the session was created/loaded successfully before import","Verify the failing appName string (shown in the exception) for invalid characters, empty value, or a duplicate already registered on the profile","Remove or correct the offending executable entry in the source .nip file and re-run the import","Update the NVIDIA display driver / nvw wrapper if DRS_CreateApplication persistently fails on valid input","Catch NvapiAddApplicationException around ImportProfiles to surface which application failed instead of aborting the whole import"],"exampleFix":"// before\nAddImportApplication(hSession, hProfile, importProfile, appName);\n// after\ntry { AddImportApplication(hSession, hProfile, importProfile, appName); }\ncatch (NvapiAddApplicationException ex)\n{\n    Logger.Warn($\"Import: could not add application '{ex.AppName}', skipping\");\n}","handlingStrategy":"try-catch","validationCode":"if (string.IsNullOrWhiteSpace(appName)) throw new ArgumentException(\"Executable name required\");\nif (profile.Executeables.GroupBy(a => a, StringComparer.OrdinalIgnoreCase).Any(g => g.Count() > 1))\n    throw new InvalidOperationException(\"Duplicate executables in import file\");","typeGuard":"static bool IsValidExecutableName(string name) =>\n    !string.IsNullOrWhiteSpace(name) && name.IndexOfAny(Path.GetInvalidFileNameChars()) < 0;","tryCatchPattern":"try\n{\n    importService.ImportProfiles(path, overwrite);\n}\ncatch (NvapiAddApplicationException ex)\n{\n    Logger.Warn($\"Import failed on application '{ex.AppName}'\");\n}\ncatch (NvapiException ex)\n{\n    Logger.Error($\"Driver API failure during import: {ex.Status}\");\n}","preventionTips":["Validate executable names in the .nip file before importing","Dedupe import executables against existing profile applications case-insensitively","Catch NvapiAddApplicationException specifically so the failing app name is reported","Keep the NVIDIA driver current so DRS_CreateApplication behaves predictably"],"tags":["nvapi","drs","profile-import","driver-settings"],"backgroundTag":"api-error-response","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"}