如何使Razor View Engine使用C#6.0 [英] How to make razor view engine to use c# 6.0
问题描述
当前,我的剃刀视图引擎抛出并错误提示请使用语言版本6或更高版本。那可能只是在给我一个指示。但是我如何使剃刀使用C#6.0。我在cs文件中剩下的解决方案可以使用所有版本7的所有新功能。
Currently my razor view engine throws and error saying "Please use language version 6 or higher". That may just be resharper giving me a pointer. But how do i make razor use c# 6.0. Rest of my solution in the cs files i can use all the new version 7 features.
推荐答案
我认为这是由于项目升级到新版本的.net框架时, web.config
模板中的错误。
I believe this is due to a bug in the templates for web.config
when the project is upgraded to a newer version of the .net framework.
我能够通过进入 web.config
,找到 system.codedom
节点并进行更改来解决此问题内容如下所示:
I was able to fix this by going in to web.config
, finding the system.codedom
node, and changing the content to look like this:
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
</compilers>
这篇关于如何使Razor View Engine使用C#6.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!