错误无效的选项'6'的/ langversion;必须符合ISO-1,ISO-2,3,4,5或默认 [英] Error Invalid option '6' for /langversion; must be ISO-1, ISO-2, 3, 4, 5 or Default

查看:4947
本文介绍了错误无效的选项'6'的/ langversion;必须符合ISO-1,ISO-2,3,4,5或默认的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想针对.NET 4.6,也充分利用了最新的C#版本通过改变C#语言版本6。

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:

错误无效的选项'6'的/ langversion;必须符合ISO-1,ISO-2,3,4,5或默认

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

如果我更新 / langversion:6 在web.config的设置5它的工作原理,

If I update the /langversion:6 in Web.Config setting to 5 it works,

  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701">

但我怎么解决这个而不是诉诸降低语言版本?

But how do I resolve this without resorting to lower language version?

我在使用Visual Studio 2015年社区版,我也安装了手动以防万一它不是在默认情况下由Visual Studio 2015年安装了.NET Framework 4.6。

I am using Visual Studio 2015 Community Edition, and I have also installed .NET Framework 4.6 manually just in case it was not installed by default by Visual Studio 2015.

该项目是由Visual Studio 2015年创建了一个标准的ASP.NET MVC模板项目。

The project is a standard ASP.NET MVC template project created by Visual Studio 2015.

推荐答案

收费attantion编译器的类型中的 Web.config中文件,更改Framework版本时:

Pay attantion to compiler "type" in the Web.Config file, when changing Framework version:

4.5和C#5 -

for 4.5 and C#5 -

TYPE =Microsoft.CSharp.CSharp codeProvider ...

type="Microsoft.CSharp.CSharpCodeProvider...

4.6和C#6 -

for 4.6 and C#6 -

TYPE =微软。codeDom.Providers.DotNetCompilerPlatform.CSharp codeProvider,微软,codeDom.Providers.DotNetCompilerPlatform,版本= 1.0.0.0,文化=中性公钥= 31bf3856ad364e35

type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

<一个href="http://forums.asp.net/t/2060343.aspx?Compile%20error%20after%20changing%20NET%20Framework%20version%20in%20MVC%20project%20in%20VS%202015%20Community%20RTM">More这里信息...

这篇关于错误无效的选项'6'的/ langversion;必须符合ISO-1,ISO-2,3,4,5或默认的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆