C# Error CS1617 – Invalid option ‘{0}’ for /langversion. Use ‘/langversion:?’ to list supported values.

C# Error

CS1617 – Invalid option ‘{0}’ for /langversion. Use ‘/langversion:?’ to list supported values.

Reason for the Error & Solution

Invalid option ‘option’ for LangVersion. Use <LangVersion>?</LangVersion> to list supported values.

This error occurs if you used the 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.

Valid values for -langversion

The valid values for the language versions depend on the .NET version you are using. See 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).
latestMajor (default) The compiler accepts syntax from the latest released major version of the compiler.
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-2 (or 2) The compiler accepts only syntax that is included in ISO/IEC 23270:2006 C# (2.0).
ISO-1 (or 1) The compiler accepts only syntax that is included in ISO/IEC 23270:2003 C# (1.0/1.2).

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

C# Compiler Error CS0442 – ‘Property’: abstract properties cannot have private accessors Reason for the Error You’ll get this error...
This is a really simple one . Below is a simple example of an enum called “Designation” defined with the...
This blog post explain the usage of the Checked Block in .NET and how you can use them in Visual...