dotnet/BenchmarkDotNet · error · InvalidOperationException

Field 'ConsoleRunnerPackage' not found.

Error message

Field 'ConsoleRunnerPackage' not found.

What it means

DotTraceDiagnoser.GetRunnerPath mirrors the dotMemory one: it reflects into JetBrains.Profiler.SelfApi's DotTrace type for the private static 'ConsoleRunnerPackage' field. Thrown when that field is absent, i.e. the loaded SelfApi layout differs from what this BDN build expects.

Source

Thrown at src/BenchmarkDotNet.Diagnostics.dotTrace/DotTraceDiagnoser.cs:55

        DotTrace.StopCollectingData();
        DotTrace.SaveData();
    }

    protected override void Detach()
    {
        DotTrace.Detach();
    }

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

    protected override string GetRunnerPath()
    {
        var consoleRunnerPackageField = typeof(DotTrace).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)

View on GitHub (pinned to b515068b61)

Solutions

  1. Keep the JetBrains.Profiler.SelfApi version aligned with the one referenced by your BenchmarkDotNet.Diagnostics.dotTrace build.
  2. Clear the cached prerequisite so InitAsync re-fetches the matching package.
  3. Upgrade BenchmarkDotNet to a release matching your SelfApi layout.
Defensive patterns

Strategy: fallback

Try / catch

try { /* use dotTrace diagnoser */ }
catch (InvalidOperationException ex) when (ex.Message.Contains("ConsoleRunnerPackage"))
{
    log.Error("dotTrace SelfApi layout mismatch - align JetBrains.Profiler.SelfApi version with your BDN build.");
}

Prevention

When it happens

Trigger: The JetBrains.Profiler.SelfApi assembly resolved at runtime (via InitAsync download or NuGet) is a version where DotTrace's ConsoleRunnerPackage field was renamed/removed/moved. Same breakage class as the dotMemory equivalent.

Common situations: Independently upgrading the dotTrace SelfApi dependency; cached prerequisite from a different build; insider/preview JetBrains profiler build with refactored internals.

Related errors


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