netchx/netch · warning · MessageException
Server not found.
Error message
Server not found.
What it means
Thrown by MainForm profile activation when no Server in ServerComboBox has a Remark equal to profile.ServerRemark — i.e. the saved profile references a server that no longer exists (deleted or renamed). The first FirstOrDefault returns null and the guard fires before the mode lookup. It is caught immediately and shown via MessageBoxX (LogLevel.ERROR), so it is a user-facing warning rather than a crash.
Source
Thrown at Netch/Forms/MainForm.cs:944
}
// Activate Profile
if (profile == null)
{
MessageBoxX.Show(i18N.Translate("No saved profile here. Save a profile first by Ctrl+Click on the button"));
return;
}
try
{
ProfileNameText.Text = profile.ProfileName;
var server = ServerComboBox.Items.Cast<Server>().FirstOrDefault(s => s.Remark.Equals(profile.ServerRemark));
var mode = ModeComboBox.Items.Cast<Mode>().FirstOrDefault(m => m.Remark.Any(s => s.Value.Equals(profile.ModeRemark)));
if (server == null)
throw new MessageException("Server not found.");
if (mode == null)
throw new MessageException("Mode not found.");
// set active server and mode
ServerComboBox.SelectedItem = server;
ModeComboBox.SelectedItem = mode;
}
catch (MessageException exception)
{
MessageBoxX.Show(exception.Message, LogLevel.ERROR);
return;
}
await StopAsync();
ControlButton.PerformClick();
}
View on GitHub (pinned to 9d99eb1c5a)
Solutions
- Re-create or rename a server so its Remark matches profile.ServerRemark.
- Edit the profile to point at an existing server (re-save it via Ctrl+Click).
- Delete the stale profile if the server is gone for good.
- Keep server Remarks stable, or update profiles immediately after renaming a server.
Defensive patterns
Strategy: validation
Validate before calling
// Before activating a profile, confirm its referenced server still exists.
var exists = ServerComboBox.Items.Cast<Server>().Any(s => s.Remark.Equals(profile.ServerRemark));
if (!exists)
{
MessageBoxX.Show($"Profile '{profile.ProfileName}' references a server that no longer exists.", LogLevel.ERROR);
return;
} Try / catch
try { /* profile activation block */ }
catch (MessageException ex) when (ex.Message == "Server not found." || ex.Message == "Mode not found.")
{
// already shown via the surrounding catch(MessageException) -> MessageBoxX; offer to delete the stale profile.
OfferDeleteStaleProfile(profile);
} Prevention
- When deleting/renaming a server, also update or delete profiles that reference its Remark.
- Treat the Remark as a stable key — avoid renaming servers that have profiles attached.
- On startup, validate all profiles against the current server/mode lists and flag orphans.
- After importing profiles from another machine, import the matching servers too.
When it happens
Trigger: A profile was saved against a server that has since been deleted; the server's Remark was edited after the profile was created; profile import from another machine whose server list differs; empty/migrated server list with old profiles.
Common situations: User deleted a server but kept profiles that point at it; renamed a server; copied profiles.xml between machines without copying servers; data drift after a config migration.
Related errors
- AioDNS start failed.
- The {0} port is in use.
- The {0} port is reserved by system.
- Mode not found.
- Invalid tcp type {server.FakeType}
AI-assisted analysis of netchx/netch@9d99eb1c5a (2026-08-13).
Data as JSON: /api/errors/a4c1893ec493e69a.
Report an issue: GitHub.