{"record":{"id":"dbac2660bf303bb6","repo":"TechnitiumSoftware/DnsServer","slug":"dns-application-does-not-exists-applicationname","errorCode":null,"errorMessage":"DNS application does not exists: {applicationName}","messagePattern":"DNS application does not exists: (.+?)","errorType":"exception","errorClass":"DnsServerException","httpStatus":null,"severity":"warning","filePath":"DnsServerCore/Dns/Applications/DnsApplicationManager.cs","lineNumber":133,"sourceCode":"\n            if (!_applications.TryAdd(application.Name, application))\n            {\n                application.Dispose();\n                throw new DnsServerException(\"DNS application already exists: \" + application.Name);\n            }\n\n            application.ConfigUpdated += Application_ConfigUpdated;\n\n            if (refreshAppObjectList)\n                RefreshAppObjectLists();\n\n            return application;\n        }\n\n        private void UnloadApplication(string applicationName)\n        {\n            if (!_applications.TryRemove(applicationName, out DnsApplication removedApp))\n                throw new DnsServerException(\"DNS application does not exists: \" + applicationName);\n\n            RefreshAppObjectLists();\n\n            removedApp.ConfigUpdated -= Application_ConfigUpdated;\n            removedApp.Dispose();\n        }\n\n        private void Application_ConfigUpdated(object sender, EventArgs e)\n        {\n            //refresh app objects to allow sorting them as per app preference\n            RefreshAppObjectLists();\n        }\n\n        private void RefreshAppObjectLists()\n        {\n            List<IDnsRequestController> dnsRequestControllers = new List<IDnsRequestController>(1);\n            List<IDnsAuthoritativeRequestHandler> dnsAuthoritativeRequestHandlers = new List<IDnsAuthoritativeRequestHandler>(1);\n            List<IDnsRequestBlockingHandler> dnsRequestBlockingHandlers = new List<IDnsRequestBlockingHandler>(1);","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dns/Applications/DnsApplicationManager.cs#L115-L151","documentation":"Thrown by DnsApplicationManager.UnloadApplication when no application is registered under the given name (TryRemove returns false). It tells the caller the application they want to remove is not currently loaded.","triggerScenarios":"Calling UnloadApplication(applicationName) for a name not in _applications: never installed, already unloaded, name typo, or a race where another caller unloaded it first.","commonSituations":"Retry of an unload that already succeeded, UI listing stale apps, or a mismatch between requested and registered names (case/whitespace).","solutions":["Check manager.Applications.ContainsKey(name) before unloading.","Treat the 'does not exist' DnsServerException as benign if unload is idempotent in your flow.","Normalize the name (trim, casing) to match the registered key.","Avoid concurrent unload of the same application."],"exampleFix":"// before\nmanager.UnloadApplication(name); // throws if missing\n\n// after\nif (manager.Applications.ContainsKey(name))\n    manager.UnloadApplication(name);","handlingStrategy":"validation","validationCode":"if (!manager.Applications.ContainsKey(name)) return; // nothing to unload\nmanager.UnloadApplication(name);","typeGuard":"static bool ApplicationIsInstalled(DnsApplicationManager m, string name)\n    => m.Applications.ContainsKey(name);","tryCatchPattern":"try { manager.UnloadApplication(name); }\ncatch (DnsServerException ex) when (ex.Message.Contains(\"does not exists\"))\n{ /* idempotent: already unloaded */ }","preventionTips":["Make unload idempotent by catching the 'does not exist' case.","Refresh the application list before offering unload actions.","Normalize the name (trim/casing) to match the registered key."],"tags":["dns","application","runtime-state","state"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}