VS2015 new Web Project (c#6) with CS1617 Error resolution
VS2015 has added support for c#6.
In the new Web project template, by introducing NuGet package microsoft.codedom.providers.dotnetcompilerplatform:1.0.0 and adding in Web. config
<system.codedom> <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> </system.codedom>
To provide c#6.0 support for razor (legacy projects can also be added for support)
But after you modify the target frame (for example, from 4.5 to 4.6), the site will not open and prompt
Server error in "/" application. Compile ErrorDescription:An error occurred during compilation of the resource required to service the request. Please check the following specific error details and modify the source code as appropriate.
Compiler Error Message:CS1617: Option "6" is invalid for/langversion; must be ISO-1, ISO-2, 3, 4, 5, or Default
Source Error:
source file:Line:0
Show verbose compiler output:
C:\Program Files (x86) \iis express> "C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe"/t:library/ UTF8OUTPUT/R: "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP. Files\vs\ ... Microsoft (R) Visual C # Compiler version 4.6.0081.0for C # 5Copyright (c) Microsoft Corporation. All rights reserved. This compiler was provided as part of the Microsoft (R). NET Framework, and only supports language versions up to C # 5, WHI CH is no longer the latest version. For compilers this support newer versions of the C # programming language, see http://go.microsoft.com/fwlink/? Linkid=533240error CS1617: Option "6" is not valid for/langversion; must be ISO-1, ISO-2, 3, 4, 5, or Default |
|
View the configuration in Web. config, found to have been automatically modified to (seems to be generally changed CS does not change VB, to lower the change will even VB together)
<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" > <provideroption name= " CompilerVersion "value=" v4.0 "/> </compiler> <compiler language=" Vb;vbs;visualbasic;vbscript " Extension= ". vb" Type= "Microsoft.VisualBasic.VBCodeProvider, System, version=4.0.0.0, Culture=neutral, publickeytoken=b77a5c561934e089 "warninglevel=" 4 "compileroptions="/langversion:14/nowarn:41008/define:_mytype=\ " web\" /optioninfer+ "> <provideroption name=" CompilerVersion "value=" v4.0 "/> </compiler> </compilers> </system.codedom>
This is not working properly and needs to be manually modified to the original result
VS2015 new Web Project (C#6) CS1617 exception is resolved