Error Invalid option '6' for /langversion; must be ISO-1, ISO-2, 3, 4, 5 or Default

前端 未结 7 553
悲哀的现实
悲哀的现实 2020-12-13 11:58

I am trying to target .NET 4.6 and also take advantage of the latest C# version by changing the C# language version to 6.

However during compilation I got this error

相关标签:
7条回答
  • 2020-12-13 12:11

    Open NuGet Package Manager console and run this following command

    Update-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform -r

    0 讨论(0)
  • 2020-12-13 12:14

    See an answer to ASP.NET strange compilation error!.

    Downgrading your C# language to 5 only masks the problem, as soon as someone uses a C# 6 feature your website/project will break and you will still spend time fixing it again. Try the solution in the link.

    0 讨论(0)
  • 2020-12-13 12:21

    Update the following NuGet packages (whichever installed) to resolve the problem:

    • Microsoft.CodeDom.Providers.DotNetCompilerPlatform
    • Microsoft.Net.Compilers
    0 讨论(0)
  • 2020-12-13 12:22

    I had similar issue when I was loading application for the first time in visual studio 2019. Updating "Microsoft.CodeDom.Providers.DotNetCompilerPlatform" nuget to later version did the trick for me.

    0 讨论(0)
  • 2020-12-13 12:24

    1.Go to Project and select your Project properties.

    2 Select Build and Click Advanced Button.

    3.Select Language Version default.

    4.Save .

    https://youtu.be/IP8feQeWqkk

    0 讨论(0)
  • 2020-12-13 12:29

    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.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    

    More info in this forum post

    0 讨论(0)
提交回复
热议问题