TechnitiumSoftware/DnsServer · error · DnsServerException
DNS application already exists: {application.Name}
Error message
DNS application already exists: {application.Name} What it means
Thrown by DnsApplicationManager.LoadApplicationAsync when an application with the same name is already registered (TryAdd on the concurrent application map fails). The freshly loaded application is disposed and the duplicate load is aborted to keep names unique.
Source
Thrown at DnsServerCore/Dns/Applications/DnsApplicationManager.cs:119
Dispose(true);
}
#endregion
#region private
private async Task<DnsApplication> LoadApplicationAsync(string applicationFolder, bool refreshAppObjectList)
{
string applicationName = Path.GetFileName(applicationFolder);
DnsApplication application = new DnsApplication(new InternalDnsServer(_dnsServer, applicationName, applicationFolder), applicationName);
await application.InitializeAsync();
if (!_applications.TryAdd(application.Name, application))
{
application.Dispose();
throw new DnsServerException("DNS application already exists: " + application.Name);
}
application.ConfigUpdated += Application_ConfigUpdated;
if (refreshAppObjectList)
RefreshAppObjectLists();
return application;
}
private void UnloadApplication(string applicationName)
{
if (!_applications.TryRemove(applicationName, out DnsApplication removedApp))
throw new DnsServerException("DNS application does not exists: " + applicationName);
RefreshAppObjectLists();
removedApp.ConfigUpdated -= Application_ConfigUpdated;View on GitHub (pinned to d0484b6c1e)
Solutions
- Uninstall (UnloadApplication) the existing application before installing/loading the same name.
- Guard the install with a ContainsKey check (and expect a possible race).
- Ensure only one app folder per name on disk.
- Serialize install/load operations to avoid concurrent duplicate adds.
Example fix
// before
await manager.InstallApplicationAsync(name, zip); // throws if exists
// after
if (!manager.Applications.ContainsKey(name))
await manager.InstallApplicationAsync(name, zip);
else
await manager.UnloadApplication(name).ContinueWith(_ => manager.InstallApplicationAsync(name, zip)).Unwrap(); Defensive patterns
Strategy: validation
Validate before calling
if (manager.Applications.ContainsKey(name))
throw new InvalidOperationException("Application already installed: " + name);
await manager.InstallApplicationAsync(name, zip); Type guard
static bool ApplicationNotInstalled(DnsApplicationManager m, string name)
=> !m.Applications.ContainsKey(name); Try / catch
try { await manager.InstallApplicationAsync(name, zip); }
catch (DnsServerException ex) when (ex.Message.Contains("already exists"))
{ await manager.UnloadApplication(name); await manager.InstallApplicationAsync(name, zip); } Prevention
- Uninstall before reinstalling the same application name.
- Serialize install operations to avoid concurrent duplicate adds.
- Keep a single app folder per name on disk.
When it happens
Trigger: Loading/installing a DNS application whose name collides with one already in _applications: concurrent installs, re-install without uninstall, filesystem containing two app folders resolving to the same name, or a race during refresh.
Common situations: Re-running an installer that did not clean up, duplicate folders under the apps path, parallel API calls installing the same app, or a hot-reload that re-adds an existing app.
Related errors
- DNS application does not exists: {applicationName}
- The application name contains an invalid character: {invalid
- Failed to update Primary node: the Primary node's domain nam
- Scope with same name already exists.
- Scope with name '{newName}' already exists.
AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13).
Data as JSON: /api/errors/29955a52374c4d34.
Report an issue: GitHub.