icsharpcode/ILSpy · error · InvalidOperationException
The chosen settings require at least {minVersion}. Please ch
Error message
The chosen settings require at least {minVersion}. Please change the DecompilerSettings accordingly. What it means
InvalidOperationException from WholeProjectDecompiler.ValidateLanguageVersion when the LanguageVersion you set is below Settings.GetMinimumRequiredVersion(). Certain DecompilerSettings flags (record classes/structs, nullable reference types, etc.) raise the minimum C# version the emitted code needs; an explicit LangVersion below that minimum cannot compile the output, so the validator rejects it.
Source
Thrown at ICSharpCode.Decompiler/CSharp/ProjectDecompiler/WholeProjectDecompiler.cs:83
/// This is an export parameter, not decompiler state: when not set explicitly, it defaults
/// to <see cref="DecompilerSettings.GetMinimumRequiredVersion"/> of the current settings,
/// and an explicit value below that minimum is rejected (here and again when the export
/// starts) because the emitted code could not compile under it.
/// </summary>
public LanguageVersion LanguageVersion {
get { return languageVersion ?? Settings.GetMinimumRequiredVersion(); }
set {
ValidateLanguageVersion(value);
languageVersion = value;
}
}
void ValidateLanguageVersion(LanguageVersion version)
{
var minVersion = Settings.GetMinimumRequiredVersion();
if (version < minVersion)
{
throw new InvalidOperationException($"The chosen settings require at least {minVersion}." +
" Please change the DecompilerSettings accordingly.");
}
}
bool IProjectInfoProvider.CheckForOverflowUnderflow => Settings.CheckForOverflowUnderflow;
public IAssemblyResolver AssemblyResolver { get; }
public IAssemblyReferenceClassifier AssemblyReferenceClassifier { get; }
public IDebugInfoProvider? DebugInfoProvider { get; }
/// <summary>
/// The MSBuild ProjectGuid to use for the new project.
/// </summary>
public Guid ProjectGuid { get; }
/// <summary>
View on GitHub (pinned to 60c08fcb74)
Solutions
- Raise LanguageVersion to at least Settings.GetMinimumRequiredVersion(), or leave it unset so it defaults to that minimum.
- Disable the DecompilerSettings flags that raised the minimum if you must target an older C#.
- Check before assigning: var min = Settings.GetMinimumRequiredVersion(); if (desired < min) desired = min;.
Example fix
// before settings.RecordClasses = true; projectDecompiler.LanguageVersion = LanguageVersion.CSharp7_3; // below the raised minimum // after settings.RecordClasses = true; projectDecompiler.LanguageVersion = settings.GetMinimumRequiredVersion(); // at least the required version
Defensive patterns
Strategy: validation
Validate before calling
var min = settings.GetMinimumRequiredVersion();
if (desiredLanguageVersion < min)
desiredLanguageVersion = min; // or disable the flags that raised the minimum
projectDecompiler.LanguageVersion = desiredLanguageVersion; Prevention
- Always derive LangVersion from GetMinimumRequiredVersion() after changing feature flags.
- Do not carry an old pinned LangVersion across a settings change.
When it happens
Trigger: Setting projectDecompiler.LanguageVersion (or the export LangVersion) to an older value after enabling features whose decompiled output needs a newer C#, e.g. enabled RecordClasses (needs C# 9+) but set LanguageVersion to C# 7.3.
Common situations: Bulk-enabling DecompilerSettings flags without raising LanguageVersion; loading settings from an old config that pins LangVersion to an earlier C#.
Related errors
- Cannot use an uncached type system in the decompiler.
- Cannot decompile this assembly to a SDK style project. Use d
AI-assisted analysis of icsharpcode/ILSpy@60c08fcb74 (2026-08-13).
Data as JSON: /api/errors/cab4d329d2f65d28.
Report an issue: GitHub.