netchx/netch · error · MessageException

bin\{mainFile} file not found!

Error message

bin\{mainFile} file not found!

What it means

Thrown by the Guard base constructor when the managed wrapper for an external binary (e.g. pcap2socks.exe, v2ray/xray, other tools under Netch\bin) cannot be found on disk. Path.GetFullPath($"bin\{mainFile}") is resolved relative to the current working directory (Global.NetchDir), and File.Exists is checked before the Process is even constructed. This is a hard precondition failure: the controller cannot launch its child process.

Source

Thrown at Netch/Controllers/Guard.cs:25

namespace Netch.Controllers;

public abstract class Guard
{
    private FileStream? _logFileStream;
    private StreamWriter? _logStreamWriter;

    /// <param name="mainFile">application path relative of Netch\bin</param>
    /// <param name="redirectOutput"></param>
    /// <param name="encoding">application output encode</param>
    protected Guard(string mainFile, bool redirectOutput = true, Encoding? encoding = null)
    {
        RedirectOutput = redirectOutput;

        var fileName = Path.GetFullPath($"bin\\{mainFile}");

        if (!File.Exists(fileName))
            throw new MessageException(i18N.Translate($"bin\\{mainFile} file not found!"));

        Instance = new Process
        {
            StartInfo =
            {
                FileName = fileName,
                WorkingDirectory = $"{Global.NetchDir}\\bin",
                CreateNoWindow = true,
                UseShellExecute = !RedirectOutput,
                RedirectStandardOutput = RedirectOutput,
                StandardOutputEncoding = RedirectOutput ? encoding : null,
                RedirectStandardError = RedirectOutput,
                StandardErrorEncoding = RedirectOutput ? encoding : null,
                WindowStyle = ProcessWindowStyle.Hidden
            }
        };
    }

View on GitHub (pinned to 9d99eb1c5a)

Solutions

  1. Confirm the file exists: check Netch\bin\<mainFile> in File Explorer or with File.Exists at the resolved full path.
  2. Re-download/re-extract the official release so the complete bin directory is present.
  3. If antivirus removed it, add an exclusion for the Netch directory and restore the file.
  4. Ensure Global.NetchDir (and the process working directory) is the folder that actually contains bin\.
Defensive patterns

Strategy: validation

Validate before calling

string resolved = Path.GetFullPath(Path.Combine(Global.NetchDir, "bin", mainFile));
if (!File.Exists(resolved))
    throw new FileNotFoundException($"Required binary missing: {resolved}", resolved);

Try / catch

try { controller = new SomeGuard("tool.exe"); }
catch (MessageException ex) when (ex.Message.Contains("file not found!"))
{
    // surface a repair prompt / offer to re-download the bin folder
    NotifyUser("Netch installation is incomplete: bin\\" + mainFile + " missing.");
}

Prevention

When it happens

Trigger: Constructing any Guard subclass (PcapController passes 'pcap2socks.exe', V2rayController/other controllers pass their binary name) when the named file is absent from Netch\bin; running Netch from a directory other than Global.NetchDir so the relative path resolves wrong; antivirus deleting the bundled exe.

Common situations: Partial extract of a release zip that dropped the bin folder; security software quarantining proxy binaries; building from source without publishing the bin dependencies; moving the Netch folder and leaving bin behind.

Related errors


AI-assisted analysis of netchx/netch@9d99eb1c5a (2026-08-13). Data as JSON: /api/errors/9790f0f433ae1f2d. Report an issue: GitHub.