{"record":{"id":"4dc448ec9de5e331","repo":"Orbmu2k/nvidiaProfileInspector","slug":"drs-enumapplications","errorCode":null,"errorMessage":"DRS_EnumApplications","messagePattern":"DRS_EnumApplications","errorType":"exception","errorClass":"NvapiException","httpStatus":null,"severity":"error","filePath":"nvidiaProfileInspector/Common/DrsSettingsServiceBase.cs","lineNumber":403,"sourceCode":"                }\n            }\n\n            return settings.ToList();\n        }\n\n        protected List<NVDRS_APPLICATION_V4> GetProfileApplications(IntPtr hSession, IntPtr hProfile)\n        {\n            uint appCount = 512;\n            var apps = new NVDRS_APPLICATION_V4[512];\n            apps[0].version = NvapiDrsWrapper.NVDRS_APPLICATION_VER_V4;\n\n            var esRes = NvapiDrsWrapper.Instance.DRS_EnumApplications(hSession, hProfile, 0, ref appCount, ref apps);\n\n            if (esRes == NvAPI_Status.NVAPI_END_ENUMERATION)\n                return new List<NVDRS_APPLICATION_V4>();\n\n            if (esRes != NvAPI_Status.NVAPI_OK)\n                throw new NvapiException(\"DRS_EnumApplications\", esRes);\n\n            return apps.ToList();\n        }\n\n        protected IntPtr FindApplicationByName(IntPtr hSession, string appName)\n        {\n            IntPtr hProfile = IntPtr.Zero;\n            NVDRS_APPLICATION_V4 app = new NVDRS_APPLICATION_V4();\n            app.version = NvapiDrsWrapper.NVDRS_APPLICATION_VER_V4;\n\n            var res = NvapiDrsWrapper.Instance.DRS_FindApplicationByName(hSession, new StringBuilder(appName), ref hProfile, ref app);\n\n            if (res != NvAPI_Status.NVAPI_OK)\n                throw new NvapiException(\"DRS_FindApplicationByName\", res);\n\n            return hProfile;\n        }\n","sourceCodeStart":385,"sourceCodeEnd":421,"githubUrl":"https://github.com/Orbmu2k/nvidiaProfileInspector/blob/2f50c388b3a4d661cade66b32746bec096d1eee1/nvidiaProfileInspector/Common/DrsSettingsServiceBase.cs#L385-L421","documentation":"NvapiException wrapping a non-OK, non-END_ENUMERATION status from DRS_EnumApplications, which lists the applications attached to a profile. NVAPI_END_ENUMERATION is treated as an empty list; any other failure status is thrown. Raised in GetProfileApplications, which feeds the applications view (otherApps).","triggerScenarios":"Calling GetProfileApplications with an invalid hProfile or a session that was destroyed; the profile handle belongs to another DRS session; the underlying struct version (NVDRS_APPLICATION_VER) mismatches the driver's expected version; driver state changed between calls.","commonSituations":"Enumerating applications on the base/global profile after a driver update invalidated handles; mixing handles from two sessions; struct version constants lagging a new NVIDIA driver release causing NVAPI_INCOMPATIBLE_STRUCT_VERSION.","solutions":["Log the wrapped NVAPI status to distinguish handle invalidation from struct-version mismatch","Re-create the session and re-acquire the profile handle, then retry enumeration","Keep NVDRS_APPLICATION_VER_V4 (and other version constants) in sync with the bundled NVAPI header version for the target driver","Only use hSession/hProfile handles obtained from the same DRS session instance"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (hSession == IntPtr.Zero || hProfile == IntPtr.Zero) throw new InvalidOperationException(\"DRS session/profile not open\");","typeGuard":null,"tryCatchPattern":"try { apps = GetProfileApplications(hSession, hProfile); }\ncatch (NvapiException ex) { Log.Warn($\"DRS_EnumApplications failed: {ex.Status}\"); apps = new List<NVDRS_APPLICATION_V4>(); }","preventionTips":["Keep NVDRS_APPLICATION_VER version constants matched to the bundled NVAPI header","Never mix handles across DRS sessions","Reopen the profile after driver reloads","Treat non-OK statuses as recoverable and log them"],"tags":["nvapi","driver-settings","native-interop"],"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"}