Invalid option ‘7.3’ for /langversion; must be ISO-1, ISO-2, Default, Latest or a valid version in range 1 to 7.1.

Invalid option ‘7.3’ for /langversion; must be ISO-1, ISO-2, Default, Latest or a valid version in range 1 to 7.1.

Md Rijwan Ansari's avatarRijwan Ansari's Blog

This compiler error occurs sometime because of version change where dotnet compiler version and c# version are incompatible.

Error:

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.            
Compiler Error Message: CS1617: Invalid option ‘6’ for /langversion; must be ISO-1, ISO-2, 3, 4, 5 or Default


Compiler Error Message: Invalid option ‘7.3’ for /langversion; must be ISO-1, ISO-2, Default, Latest or a valid version in range 1 to 7.1.


Solution:

Solution 1: The easiest way is to update the following NuGet packages (whichever installed) to resolve the problem:

  • Microsoft.CodeDom.Providers.DotNetCompilerPlatform
  • Microsoft.Net.Compilers


Solution 2: Pay attention to compiler “type” in the Web.Config file, when changing Framework version:

for 4.5 and C#5 –

type="Microsoft.CSharp.CSharpCodeProvider...

for 4.6 and C#6 –

type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatfor

Workaround:

<system.codedom> <compilers> <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"…

View original post 36 more words

Leave a comment