dotnet/BenchmarkDotNet · error · InvalidOperationException

Method 'GetRunnerPath' not found.

Error message

Method 'GetRunnerPath' not found.

What it means

GetRunnerPath located the ConsoleRunnerPackage instance but its runtime type has no 'GetRunnerPath' method. The SelfApi package type layout changed: the method was renamed, signature-changed, or moved to a different type than the one BDN reflects against.

Source

Thrown at src/BenchmarkDotNet.Diagnostics.dotMemory/DotMemoryDiagnoser.cs:61

    protected override string CreateSnapshotFilePath(DiagnoserActionParameters parameters)
    {
        return ArtifactFileNameHelper.GetFilePath(parameters, "snapshots", DateTime.Now, "dmw", ".0000".Length);
    }

    protected override string GetRunnerPath()
    {
        var consoleRunnerPackageField = typeof(DotMemory).GetField("ConsoleRunnerPackage", BindingFlags.NonPublic | BindingFlags.Static);
        if (consoleRunnerPackageField == null)
            throw new InvalidOperationException("Field 'ConsoleRunnerPackage' not found.");

        object? consoleRunnerPackage = consoleRunnerPackageField.GetValue(null);
        if (consoleRunnerPackage == null)
            throw new InvalidOperationException("Unable to get value of 'ConsoleRunnerPackage'.");

        var consoleRunnerPackageType = consoleRunnerPackage.GetType();
        var getRunnerPathMethod = consoleRunnerPackageType.GetMethod("GetRunnerPath");
        if (getRunnerPathMethod == null)
            throw new InvalidOperationException("Method 'GetRunnerPath' not found.");

        string? runnerPath = getRunnerPathMethod.Invoke(consoleRunnerPackage, null) as string;
        if (runnerPath == null)
            throw new InvalidOperationException("Unable to invoke 'GetRunnerPath'.");

        return runnerPath;
    }

    internal override bool IsSupported(RuntimeMoniker runtimeMoniker)
    {
        switch (runtimeMoniker)
        {
            case RuntimeMoniker.HostProcess:
            case RuntimeMoniker.Net461:
            case RuntimeMoniker.Net462:
            case RuntimeMoniker.Net47:
            case RuntimeMoniker.Net471:
            case RuntimeMoniker.Net472:

View on GitHub (pinned to b515068b61)

Solutions

  1. Pin/restore the JetBrains.Profiler.SelfApi version declared by your BenchmarkDotNet build.
  2. Clear the SelfApi prerequisite cache and re-run InitAsync to fetch the matching package.
  3. Upgrade BenchmarkDotNet to a release compatible with the SelfApi layout you use.
Defensive patterns

Strategy: fallback

Try / catch

try { /* use dotMemory diagnoser */ }
catch (InvalidOperationException ex) when (ex.Message.Contains("Method 'GetRunnerPath' not found"))
{
    log.Error("dotMemory SelfApi method renamed/moved; align SelfApi version with BDN.");
}

Prevention

When it happens

Trigger: A JetBrains.Profiler.SelfApi version in which the runner-package type no longer exposes a parameterless GetRunnerPath() method. Same class of breakage as the missing-field error, just one reflection step later.

Common situations: SelfApi package upgraded out of sync with BDN; cached prerequisite from a newer/older build; insider build of the JetBrains profiler with a refactored API.

Related errors


AI-assisted analysis of dotnet/BenchmarkDotNet@b515068b61 (2026-08-13). Data as JSON: /api/errors/29958a47a52112e6. Report an issue: GitHub.