netchx/netch · error · NotSupportedException
Specified server type is not supported.
Error message
Specified server type is not supported.
What it means
ServerHelper builds ServerUtilDictionary once, via reflection over every exported type in the executing assembly that implements IServerUtil, keyed by each util's TypeName. GetUtilByTypeName returns the util for a TypeName or throws NotSupportedException if it is not registered. So the error means a Server.Type value has no matching IServerUtil implementation loaded in this assembly - typically a protocol this Netch build does not ship support for, or a corrupted/imported Type field. Note Server.ToString() also calls GetUtilByTypeName, so even rendering a bad server in a list can trigger it.
Source
Thrown at Netch/Utils/ServerHelper.cs:21
namespace Netch.Utils;
public static class ServerHelper
{
static ServerHelper()
{
var serversUtilsTypes = Assembly.GetExecutingAssembly()
.GetExportedTypes()
.Where(type => type.GetInterfaces().Contains(typeof(IServerUtil)));
ServerUtilDictionary = serversUtilsTypes.Select(t => (IServerUtil)Activator.CreateInstance(t)!).ToDictionary(util => util.TypeName);
}
public static Dictionary<string, IServerUtil> ServerUtilDictionary { get; }
public static IServerUtil GetUtilByTypeName(string typeName)
{
return ServerUtilDictionary.GetValueOrDefault(typeName) ?? throw new NotSupportedException("Specified server type is not supported.");
}
public static IServerUtil? GetUtilByUriScheme(string scheme)
{
return ServerUtilDictionary.Values.SingleOrDefault(i => i.UriScheme.Any(s => s.Equals(scheme)));
}
public static Type GetTypeByTypeName(string typeName)
{
return GetUtilByTypeName(typeName).ServerType;
}
}View on GitHub (pinned to 9d99eb1c5a)
Solutions
- Update Netch to a version that supports the server's Type.
- Remove the unsupported server entries from settings.json / the server list.
- Re-import the server using a supported protocol.
- If developing a custom protocol, ensure its IServerUtil implementation is compiled into the executing assembly so reflection picks it up.
Example fix
// before
return ServerUtilDictionary.GetValueOrDefault(typeName) ?? throw new NotSupportedException("Specified server type is not supported.");
// after - return null and let callers skip unknown servers gracefully
return ServerUtilDictionary.GetValueOrDefault(typeName); Defensive patterns
Strategy: validation
Validate before calling
if (!ServerHelper.ServerUtilDictionary.ContainsKey(server.Type))
{
Log.Warning("Skipping server '{Remark}': unknown type '{Type}'", server.Remark, server.Type);
continue; // or remove the entry
}
var util = ServerHelper.GetUtilByTypeName(server.Type); Type guard
bool IsSupportedServerType(string typeName) => ServerHelper.ServerUtilDictionary.ContainsKey(typeName);
Try / catch
try { var util = ServerHelper.GetUtilByTypeName(typeName); }
catch (NotSupportedException)
{
Log.Warning("Unsupported server type '{Type}' skipped", typeName);
continue;
} Prevention
- On config load, filter out servers whose Type is not in ServerUtilDictionary and log them.
- Guard Server.ToString() against missing utils so a single bad server does not crash UI rendering.
- When removing a protocol in a release, migrate or prune affected entries from existing configs.
- Add a startup assertion logging how many IServerUtil types were registered, to catch empty registration from a failed assembly load.
When it happens
Trigger: Deserializing a settings.json whose server has a Type with no matching IServerUtil; loading a config from a Netch version that removed a server type present in this one; a Server.ToString() call (UI binding) on such a server; the reflection dictionary built before the util assembly was loaded.
Common situations: Downgrading Netch across a release that removed a server type; importing a share link whose scheme maps to an unimplemented type; a custom server plugin not present in this build; a hand-edited Type field in settings.json.
Related errors
- AioDNS start failed.
- The {0} port is in use.
- The {0} port is reserved by system.
- Server not found.
- Invalid tcp type {server.FakeType}
AI-assisted analysis of netchx/netch@9d99eb1c5a (2026-08-13).
Data as JSON: /api/errors/e3a8a6c0bf5cca57.
Report an issue: GitHub.