<small id='QLcJG'></small><noframes id='QLcJG'>

        <tfoot id='QLcJG'></tfoot><legend id='QLcJG'><style id='QLcJG'><dir id='QLcJG'><q id='QLcJG'></q></dir></style></legend>
          <bdo id='QLcJG'></bdo><ul id='QLcJG'></ul>
        <i id='QLcJG'><tr id='QLcJG'><dt id='QLcJG'><q id='QLcJG'><span id='QLcJG'><b id='QLcJG'><form id='QLcJG'><ins id='QLcJG'></ins><ul id='QLcJG'></ul><sub id='QLcJG'></sub></form><legend id='QLcJG'></legend><bdo id='QLcJG'><pre id='QLcJG'><center id='QLcJG'></center></pre></bdo></b><th id='QLcJG'></th></span></q></dt></tr></i><div id='QLcJG'><tfoot id='QLcJG'></tfoot><dl id='QLcJG'><fieldset id='QLcJG'></fieldset></dl></div>
      1. C# 7 功能在 Visual Studio 2017 RC 上的 Web 项目中不起作用

        C# 7 features don#39;t work within a web project on Visual Studio 2017 RC(C# 7 功能在 Visual Studio 2017 RC 上的 Web 项目中不起作用)
          <tbody id='SUqzZ'></tbody>
          <bdo id='SUqzZ'></bdo><ul id='SUqzZ'></ul>

                  <legend id='SUqzZ'><style id='SUqzZ'><dir id='SUqzZ'><q id='SUqzZ'></q></dir></style></legend>

                  <small id='SUqzZ'></small><noframes id='SUqzZ'>

                  <tfoot id='SUqzZ'></tfoot>
                  <i id='SUqzZ'><tr id='SUqzZ'><dt id='SUqzZ'><q id='SUqzZ'><span id='SUqzZ'><b id='SUqzZ'><form id='SUqzZ'><ins id='SUqzZ'></ins><ul id='SUqzZ'></ul><sub id='SUqzZ'></sub></form><legend id='SUqzZ'></legend><bdo id='SUqzZ'><pre id='SUqzZ'><center id='SUqzZ'></center></pre></bdo></b><th id='SUqzZ'></th></span></q></dt></tr></i><div id='SUqzZ'><tfoot id='SUqzZ'></tfoot><dl id='SUqzZ'><fieldset id='SUqzZ'></fieldset></dl></div>
                  本文介绍了C# 7 功能在 Visual Studio 2017 RC 上的 Web 项目中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我在解决方案中有几个项目,C# 7 功能(例如元组和 throw 表达式)在所有库项目中都可以正常工作,但是有一个(非核心)Web 项目由于以下原因无法编译C# 7 功能上的错误.编译后,错误窗口很快就会自行清除,可能是因为 IDE/编辑器编译相同的单元而没有错误.我必须使用输出窗口来查看编译器错误.就好像 IDE/编辑器假设 C# 7,但构建中使用的编译器不是.

                  I have several projects in the solution, and the C# 7 features, such as tuples and throw expressions, work fine in all of the library projects, but there is a (non Core) web project that doesn't compile due to errors on the C# 7 features. Right after compiling, the error window quickly clears itself, presumably because the IDE/editor compiles the same units without error. I have to use the output window to see the compiler errors. It is as though the IDE/editor are assuming C# 7, but the compiler used in the build is not.

                  我尝试将__DEMO__,__DEMO_EXPERIMENTAL__"添加到条件编译符号中,但无济于事.我尝试过针对不同版本的框架并编辑了 web.config,包括 system.webcompilationtargetFramework 标签.

                  I've tried adding "__DEMO__,__DEMO_EXPERIMENTAL__" to the conditional compilation symbols, to no avail. I've experimented with targeting different version of the framework and have edited the web.config, including the compilation and targetFramework tags of system.web.

                  错误示例:

                  if (!config.Properties.TryGetValue(modelId, out var model)) // error CS1003: Syntax error, ',' expected
                  if (modelDescription is ComplexTypeModelDescription complexTypeModelDescription) // error CS1026: ) expected
                  

                  这是项目的 csproj 文件的前几行:

                  Here are the first few lines of the csproj file for the project:

                  <Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
                    <Import Project="..packagesMicrosoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3uildMicrosoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..packagesMicrosoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.3uildMicrosoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
                    <Import Project="..packagesMicrosoft.Net.Compilers.1.3.2uildMicrosoft.Net.Compilers.props" Condition="Exists('..packagesMicrosoft.Net.Compilers.1.3.2uildMicrosoft.Net.Compilers.props')" />
                    <Import Project="$(MSBuildExtensionsPath)$(MSBuildToolsVersion)Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)$(MSBuildToolsVersion)Microsoft.Common.props')" />
                  

                  更新:我尝试使用 VS 2017 RC 中的最新模板创建一个新的 Web 项目并复制到我的源文件中.一样.

                  Update: I tried creating a new web project using the latest template in VS 2017 RC and copying in my source files. Same thing.

                  我也尝试过明确设置 Project |属性 |构建 |高级 |语言版本为 7.导致/langversion 的选项 '7' 无效".

                  I also tried explicitly setting Project | Properties | Build | Advanced | Language Version to 7. Results in "Invalid option '7' for /langversion".

                  推荐答案

                  解决方案 是将 Microsoft.Net.Compilers nuget 包更新为 >=2.0.0.到目前为止,要显示 2.0.0 版本,必须选中包管理器顶部的包含预发布"复选框.安装后,Language version 高级设置不必从 Default 覆盖.

                  The solution is to update the Microsoft.Net.Compilers nuget package to >=2.0.0. As of now, for the 2.0.0 version to appear, the "Include prerelease" checkbox at the top of the package manager must be checked. With this installed, the Language version advanced setting doesn't have to be overridden from Default.

                  这篇关于C# 7 功能在 Visual Studio 2017 RC 上的 Web 项目中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  JSON.Net custom contract serialization and Collections(JSON.Net 自定义合约序列化和集合)
                  c# JSON Serialization Use Value Instead of Property Name(c# JSON序列化使用值而不是属性名)
                  Automatically bind pascal case c# model from snake case JSON in WebApi(从 WebApi 中的蛇案例 JSON 自动绑定帕斯卡案例 c# 模型)
                  #39;Could not load type #39;Microsoft.AspNetCore.Mvc.MvcJsonOptions#39; from assembly #39;Microsoft.AspNetCore.Mvc.Formatters.Json, Version=3.0.0.0(无法从程序集Microsoft.AspNetCore.Mvc.Formatters.Json 加载类型Microsoft.AspNetCore.Mvc.MvcJso
                  json.net; serialize entity framework object (circular reference error)(json.net;序列化实体框架对象(循环引用错误))
                  Windows installer using the NT AUTHORITYSYSTEM instead of login user(Windows 安装程序使用 NT AUTHORITYSYSTEM 而不是登录用户)

                    • <tfoot id='yTwow'></tfoot>

                        <bdo id='yTwow'></bdo><ul id='yTwow'></ul>

                      • <i id='yTwow'><tr id='yTwow'><dt id='yTwow'><q id='yTwow'><span id='yTwow'><b id='yTwow'><form id='yTwow'><ins id='yTwow'></ins><ul id='yTwow'></ul><sub id='yTwow'></sub></form><legend id='yTwow'></legend><bdo id='yTwow'><pre id='yTwow'><center id='yTwow'></center></pre></bdo></b><th id='yTwow'></th></span></q></dt></tr></i><div id='yTwow'><tfoot id='yTwow'></tfoot><dl id='yTwow'><fieldset id='yTwow'></fieldset></dl></div>
                          <tbody id='yTwow'></tbody>

                          <small id='yTwow'></small><noframes id='yTwow'>

                            <legend id='yTwow'><style id='yTwow'><dir id='yTwow'><q id='yTwow'></q></dir></style></legend>