dotnet/BenchmarkDotNet · error · ArgumentException
Can not emit base call for {constructorBuilder}
Error message
Can not emit base call for {constructorBuilder} What it means
IlGeneratorStatementExtensions.EmitCallBaseParameterlessCtor (internal) refuses to emit a base-constructor call for a static ConstructorBuilder: a static constructor has no base instance ctor to call. It throws ArgumentException. This is an internal precondition of generated-type construction.
Source
Thrown at src/BenchmarkDotNet/Helpers/Reflection.Emit/IlGeneratorStatementExtensions.cs:11
using System.Reflection;
using System.Reflection.Emit;
namespace BenchmarkDotNet.Helpers.Reflection.Emit
{
internal static class IlGeneratorStatementExtensions
{
public static void EmitCallBaseParameterlessCtor(this ILGenerator ilGenerator, ConstructorBuilder constructorBuilder)
{
if (constructorBuilder.IsStatic)
throw new ArgumentException($"Can not emit base call for {constructorBuilder}");
if (constructorBuilder.DeclaringType == null)
throw new ArgumentException($"The {nameof(constructorBuilder)} should have non-null {nameof(constructorBuilder.DeclaringType)}.");
/*
IL_0000: ldarg.0
IL_0001: call instance void [BenchmarkDotNet]BenchmarkDotNet.Samples.SampleBenchmark::.ctor()
*/
var baseCtor = constructorBuilder.DeclaringType.BaseType?.GetConstructor([]);
if (baseCtor == null)
throw new ArgumentException(
$"Base type of {constructorBuilder.DeclaringType} has no public parameterless constructor.");
ilGenerator.Emit(OpCodes.Ldarg_0);
ilGenerator.Emit(OpCodes.Call, baseCtor);
}
public static void EmitCtorReturn(this ILGenerator ilBuilder, ConstructorBuilder methodBuilder)
{View on GitHub (pinned to b515068b61)
Solutions
- Retry with a standard benchmark class layout (no static constructor edge case).
- Upgrade BenchmarkDotNet; report the issue with a reproducible benchmark if it persists.
Defensive patterns
Strategy: try-catch
Try / catch
try { runner.Run(); }
catch (ArgumentException ex) when (ex.Message.Contains("Can not emit base call")) { /* simplify type layout, report issue */ } Prevention
- Avoid static-constructor edge cases in benchmark types.
- Keep BenchmarkDotNet current.
- Report reproducible constructor-emit errors.
When it happens
Trigger: The emitter is asked to emit a base-ctor call for a static ConstructorBuilder, which is semantically invalid.
Common situations: Library codegen bug during generation of a benchmark wrapper type; not reachable through normal user configuration.
Related errors
- Method {methodToCall} should be static method.
- The methodToCall should have non-null DeclaringType.
- Method {methodToCall} should be instance method.
- The optionalLocalThis should be null for static calls
- The constructorBuilder should have non-null DeclaringType.
AI-assisted analysis of dotnet/BenchmarkDotNet@b515068b61 (2026-08-13).
Data as JSON: /api/errors/94c6c5e34f7d5450.
Report an issue: GitHub.