Generic
Links: https://www.zhihu.com/question/48864375/answer/113316462
Source: Know
Copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source.
The problem is caused by Microsoft's failure to use the. NET Framework 4.6.1http/ASP The site created by the Empty Web site template enables C # 6 support, and the Web site does not have the same language version in the project properties-build-Advanced window as the application project, so when you use C # 6 syntax, you are prompted:
The
feature "XXX" is not available in C # 5. Please use language version 6 or later.
<img src= "https://pic1.zhimg.com/50/ef29893180be89925650df1ff654805d_hd.jpg" data-rawheight= " 392 "data-rawwidth=" 964 "class=" Origin_image zh-lightbox-thumb "width=" 964 "data-original=" https://pic1.zhimg.com/ Ef29893180be89925650df1ff654805d_r.jpg "> You can resolve this by installing the Microsoft.CodeDom.Providers.DotNetCompilerPlatform package:
Install-package Microsoft.CodeDom.Providers.DotNetCompilerPlatform after the package is installed, the following nodes are automatically added under the Configuration node in the Web. config file:
<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>
C # 6 is now ready to use.
&amp;lt;img src= "https://pic1.zhimg.com/50/d9a7fd775d69934518d46f30b2211a00_hd.jpg" data-rawheight= " 390 "data-rawwidth=" 744 "class=" Origin_image zh-lightbox-thumb "width=" 744 "data-original=" https://pic1.zhimg.com/ D9a7fd775d69934518d46f30b2211a00_r.jpg "&amp;gt; There should be no problem under normal circumstances. However, when you build your Web site, you may also encounter another problem that prompts you:
the file "Xxx\bin\roslyn\csc.exe" could not be found.
This problem may occur because VS does not correctly place the Roslyn compiler in the Roslyn folder of the Web site Bin folder. You can copy the Roslyn compiler from the NuGet package folder to the Bin/roslyn folder in your Web site. The NuGet Package folder is typically in the same directory as the. sln solution file. The path to the Roslyn compiler in the NuGet folder is:
packages\Microsoft.Net.Compilers.1.0.0\tools
Just copy all the files in this folder.
How do I use C # 6 in an ASP. NET site project?