{"record":{"id":"c432239520a53bcd","repo":"dotnet/BenchmarkDotNet","slug":"runtimemoniker-not-supported","errorCode":null,"errorMessage":"RuntimeMoniker not supported","messagePattern":"RuntimeMoniker not supported","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/BenchmarkDotNet/Toolchains/ToolchainExtensions.cs","lineNumber":223,"sourceCode":"                    return MonoToolchain.Mono10_0;\n\n                case RuntimeMoniker.Mono11_0:\n                    return MonoToolchain.Mono11_0;\n\n                case RuntimeMoniker.R2R80:\n                    return R2RToolchain.R2R80;\n\n                case RuntimeMoniker.R2R90:\n                    return R2RToolchain.R2R90;\n\n                case RuntimeMoniker.R2R10_0:\n                    return R2RToolchain.R2R10_0;\n\n                case RuntimeMoniker.R2R11_0:\n                    return R2RToolchain.R2R11_0;\n\n                default:\n                    throw new ArgumentOutOfRangeException(nameof(runtimeMoniker), runtimeMoniker, \"RuntimeMoniker not supported\");\n            }\n        }\n    }\n}\n","sourceCodeStart":205,"sourceCodeEnd":228,"githubUrl":"https://github.com/dotnet/BenchmarkDotNet/blob/b515068b61ad1c9c9aa938b8ece4af1e7d6d85a3/src/BenchmarkDotNet/Toolchains/ToolchainExtensions.cs#L205-L228","documentation":"Thrown by the private GetToolchain(RuntimeMoniker) method when a RuntimeMoniker enum value is not covered by its switch statement. This second-level resolver maps known monikers (Net*, NativeAot*, Mono*, R2R*) to concrete toolchains; any uncovered value — most notably RuntimeMoniker.NotRecognized or a moniker enum member added in a newer BDN version but not yet wired up here — hits the default and raises ArgumentOutOfRangeException. Normal callers guard NotRecognized before calling, so in practice this fires on unmapped valid enum values.","triggerScenarios":"The private GetToolchain(RuntimeMoniker) at line 117 is reached from the public GetToolchain(Runtime,...) when a runtime's RuntimeMoniker != NotRecognized (e.g. ClrRuntime line 53, CoreRuntime line 93-94, NativeAotRuntime line 99-100, R2RRuntime line 107-108). If that moniker is a real enum value with no case in the switch (e.g. a future Net12_0 added to the enum but no toolchain mapping, or NotRecognized slipping through), the default at line 222 throws.","commonSituations":"Using a RuntimeMoniker from a newer BDN enum against an older BDN runtime that lacks the toolchain constant. A version-skew between the Environments assembly (enum) and the Toolchains assembly (switch). Casting an arbitrary integer to RuntimeMoniker producing an undefined member. NotRecognized reaching the call because a caller's guard was bypassed.","solutions":["Use a RuntimeMoniker that is explicitly mapped in your BDN version (Net80, Net90, Net10_0, NativeAot80, R2R80, etc.) — check the switch in ToolchainExtensions for your version","Upgrade BenchmarkDotNet so the toolchain mappings include your target moniker","Bypass moniker dispatch entirely by setting an explicit toolchain with .WithToolchain(...) on the Job, so neither GetToolchain(Runtime) nor GetToolchain(RuntimeMoniker) is called"],"exampleFix":"// before — assumes a moniker BDN's switch does not cover\nvar job = Job.Default.WithRuntime(CoreRuntime.FromId(\"net12.0\"));\n// => if RuntimeMoniker.Net12_0 exists in the enum but has no toolchain case:\n//    ArgumentOutOfRangeException: RuntimeMoniker not supported\n\n// after (explicit toolchain for an unsupported moniker)\nvar job = Job.Default\n    .WithToolchain(CsProjCoreToolchain.From(\n        new NetCoreAppSettings(\"net12.0\", \".NET 12\")));","handlingStrategy":"validation","validationCode":"// Verify a RuntimeMoniker is one BDN actually maps to a toolchain before relying on automatic dispatch.\nusing System.Reflection;\nusing BenchmarkDotNet.Environments;\n\nstatic readonly HashSet<RuntimeMoniker> MappedMonikers = new()\n{\n    RuntimeMoniker.Net461, RuntimeMoniker.Net462, RuntimeMoniker.Net47, RuntimeMoniker.Net471,\n    RuntimeMoniker.Net472, RuntimeMoniker.Net48, RuntimeMoniker.Net481,\n    RuntimeMoniker.NetCoreApp20, RuntimeMoniker.NetCoreApp21, RuntimeMoniker.NetCoreApp22,\n    RuntimeMoniker.NetCoreApp30, RuntimeMoniker.NetCoreApp31,\n    RuntimeMoniker.Net50, RuntimeMoniker.Net60, RuntimeMoniker.Net70, RuntimeMoniker.Net80,\n    RuntimeMoniker.Net90, RuntimeMoniker.Net10_0, RuntimeMoniker.Net11_0,\n    RuntimeMoniker.NativeAot70, RuntimeMoniker.NativeAot80, RuntimeMoniker.NativeAot90,\n    RuntimeMoniker.NativeAot10_0, RuntimeMoniker.NativeAot11_0,\n    RuntimeMoniker.Mono60, RuntimeMoniker.Mono70, RuntimeMoniker.Mono80,\n    RuntimeMoniker.Mono90, RuntimeMoniker.Mono10_0, RuntimeMoniker.Mono11_0,\n    RuntimeMoniker.R2R80, RuntimeMoniker.R2R90, RuntimeMoniker.R2R10_0, RuntimeMoniker.R2R11_0,\n};\n\nstatic void EnsureMappedMoniker(RuntimeMoniker m)\n{\n    if (!MappedMonikers.Contains(m))\n        throw new ArgumentOutOfRangeException(\n            nameof(m), $\"RuntimeMoniker {m} has no toolchain mapping in this BDN version; set an explicit toolchain.\");\n}","typeGuard":"// Narrow a RuntimeMoniker to the set that has a concrete toolchain.\nstatic bool IsMonikerMapped(RuntimeMoniker m) => m != RuntimeMoniker.NotRecognized && MappedMonikers.Contains(m);","tryCatchPattern":"try { BenchmarkRunner.Run<MyBench>(); }\ncatch (ArgumentOutOfRangeException ex) when (ex.Message.Contains(\"RuntimeMoniker not supported\"))\n{\n    throw new InvalidOperationException(\n        \"The RuntimeMoniker has no toolchain mapping in this BDN version. \" +\n        \"Upgrade BDN or set an explicit toolchain via .WithToolchain(...).\", ex);\n}","preventionTips":["Set an explicit toolchain with .WithToolchain(...) for any cutting-edge or preview moniker so dispatch never reaches the unmapped default.","Upgrade BenchmarkDotNet in lockstep with new .NET versions so new RuntimeMoniker members have matching toolchain cases.","Never pass RuntimeMoniker.NotRecognized into a job expecting automatic toolchain resolution; it is explicitly excluded by all callers."],"tags":["toolchain","runtime-moniker","dispatch","argument-out-of-range","version-skew"],"backgroundTag":null,"analyzedSha":"b515068b61ad1c9c9aa938b8ece4af1e7d6d85a3","analyzedAt":"2026-08-13T19:12:24.196Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}