Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Invalid option 'option' for LangVersion. Use ? to list supported values.
This error occurs if you used the LangVersion command line switch or project setting but didn't specify a valid language option. To resolve this error, check the command line syntax or project setting and change it to one of the listed options.
For example, compiling with csc -langversion:ISO will generate error CS1617.
How to list supported language versions
To see a list of supported language versions, you reference the table in this article, compile with -langversion:?, or temporarily set <LangVersion>?</LangVersion> in your project file before building.
Use the reference table (recommended)
The most reliable way to see supported language versions is to consult the reference table at the end of this article, which lists all currently supported language versions.
Use the C# compiler directly
Use the -langversion:? option with the C# compiler. You need to find the path to csc.dll in your .NET SDK installation:
dotnet exec "/path/to/dotnet/sdk/version/Roslyn/bincore/csc.dll" -langversion:?
For example, on Linux with .NET 8 SDK:
dotnet exec "/usr/lib/dotnet/sdk/8.0.117/Roslyn/bincore/csc.dll" -langversion:?
The exact path varies based on your operating system and .NET SDK version.
Use a project file with diagnostic output (not recommended)
You can temporarily set <LangVersion>?</LangVersion> in your project file and build with diagnostic verbosity:
dotnet build -v diagnostic
Look for the "Supported language versions:" line in the output.
Warning
Setting <LangVersion>?</LangVersion> in a project file will cause the build to fail after displaying the supported versions. This is because the compiler exits after listing the versions instead of continuing to compile your code. Remove this setting after viewing the list.
Valid values for -langversion
The valid values for the language versions depend on the .NET version you are using. See the language version rules for more information on which language version is available with which version of .NET. If you are receiving this error while attempting to use a newer language version, either downgrade to a lower language version or update your .NET SDK to a version that supports the language version.
The following table specifies the current valid values for -langversion:
| Value | Meaning |
|---|---|
preview |
The compiler accepts all valid language syntax from the latest preview version. |
latest |
The compiler accepts syntax from the latest released version of the compiler (including minor version). |
latestMajoror default |
The compiler accepts syntax from the latest released major version of the compiler. |
14.0 |
The compiler accepts only syntax that is included in C# 14 or lower. |
13.0 |
The compiler accepts only syntax that is included in C# 13 or lower. |
12.0 |
The compiler accepts only syntax that is included in C# 12 or lower. |
11.0 |
The compiler accepts only syntax that is included in C# 11 or lower. |
10.0 |
The compiler accepts only syntax that is included in C# 10 or lower. |
9.0 |
The compiler accepts only syntax that is included in C# 9 or lower. |
8.0 |
The compiler accepts only syntax that is included in C# 8.0 or lower. |
7.3 |
The compiler accepts only syntax that is included in C# 7.3 or lower. |
7.2 |
The compiler accepts only syntax that is included in C# 7.2 or lower. |
7.1 |
The compiler accepts only syntax that is included in C# 7.1 or lower. |
7 |
The compiler accepts only syntax that is included in C# 7.0 or lower. |
6 |
The compiler accepts only syntax that is included in C# 6.0 or lower. |
5 |
The compiler accepts only syntax that is included in C# 5.0 or lower. |
4 |
The compiler accepts only syntax that is included in C# 4.0 or lower. |
3 |
The compiler accepts only syntax that is included in C# 3.0 or lower. |
ISO-2or 2 |
The compiler accepts only syntax that is included in ISO/IEC 23270:2006 C# (2.0). |
ISO-1or 1 |
The compiler accepts only syntax that is included in ISO/IEC 23270:2003 C# (1.0/1.2). |