• <bdo id='9t1xc'></bdo><ul id='9t1xc'></ul>
  • <legend id='9t1xc'><style id='9t1xc'><dir id='9t1xc'><q id='9t1xc'></q></dir></style></legend>

    1. <tfoot id='9t1xc'></tfoot>

        <small id='9t1xc'></small><noframes id='9t1xc'>

      1. <i id='9t1xc'><tr id='9t1xc'><dt id='9t1xc'><q id='9t1xc'><span id='9t1xc'><b id='9t1xc'><form id='9t1xc'><ins id='9t1xc'></ins><ul id='9t1xc'></ul><sub id='9t1xc'></sub></form><legend id='9t1xc'></legend><bdo id='9t1xc'><pre id='9t1xc'><center id='9t1xc'></center></pre></bdo></b><th id='9t1xc'></th></span></q></dt></tr></i><div id='9t1xc'><tfoot id='9t1xc'></tfoot><dl id='9t1xc'><fieldset id='9t1xc'></fieldset></dl></div>

      2. 如何在 ASP.NET 网站项目中使用最新的 VB.NET 语言级别?

        How can I use the latest VB.NET language level in an ASP.NET web site project?(如何在 ASP.NET 网站项目中使用最新的 VB.NET 语言级别?)
            <tbody id='qDPrk'></tbody>

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

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

            • <bdo id='qDPrk'></bdo><ul id='qDPrk'></ul>
                <tfoot id='qDPrk'></tfoot>

                <legend id='qDPrk'><style id='qDPrk'><dir id='qDPrk'><q id='qDPrk'></q></dir></style></legend>
                  本文介绍了如何在 ASP.NET 网站项目中使用最新的 VB.NET 语言级别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我的任务是对 2009 年开发的 Web 应用程序进行现代化改造.它是用 VB.NET 编写的,并使用 ASP.NET WebForms.我想在 VB.NET 中使用最新的语言结构.

                  我得到了有用的提示,说Visual Basic 10.0 不允许字符串插值",这是我尝试使用的,但我未能找到提高语言水平的方法.

                  我在这个相关问题中有提示

                  或者,绕过上述 GUI 功能,直接进入 Nuget 包管理器,将以下包的最新版本安装到项目/站点中,以便与 VB.NET 语言保持同步可能是:

                  • Microsoft.CodeDom.Providers.DotNetCompilerPlatform
                  • Microsoft.Net.Compilers

                  (NB 最新版本 要求 .NET 4.6+ 是安装系统上供编译器运行,但可以编译针对任何平台的代码.

                  这很可能会让您为 C# 6/VB 14 排序.获得 VB 15 的最后一步是:编辑 web.config 文件中的 langversion,使其读取为 15.0(或 latest 如果你想使用最新版本 - 这是我的首选).

                  <编译器><编译器语言=vb;vbs;visualbasic;vbscript"扩展=.vb"type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider,Microsoft.CodeDom.Providers.DotNetCompilerPlatform,版本=1.0.8.0,文化=中性,PublicKeyToken=31bf3856ad364e35"warningLevel="4" compilerOptions="/langversion:15.0/nowarn:41008/define:_MYTYPE=&quot;Web&quot;/optionInfer+"/></编译器>

                  不幸的是,在将我的 Roslyn 升级到 C# 7.0 和 7.1 之后,我发现自己不得不编辑 langversion,所以这绝对是值得关注的事情.

                  顺便说一句,这个答案不仅仅适用于项目——如果使用的模板不引用 Nuget 编译器包,即使在 VS 2017 中创建的新 Web 项目也需要这个修复.Roslyn 不是强制性的,例如模板据报道,新网站尚未更新.

                  I've been tasked with modernising a web application developed in 2009. It is written in VB.NET and using ASP.NET WebForms. I would like to use the latest language constructs in VB.NET.

                  I get helpful pointers saying "Visual Basic 10.0 does not allow string interpolation", which was what I was trying to use, but I failed to find a way to raise the language level.

                  I have the tips in this related question How to change the VB.NET language version in Visual Studio 2015, but they did not help in this context.

                  In ReSharper properties, I could set the "VB Language Level" for each of the four different projects to "Visual Basic .NET 15". This changes a line of XML in the project's .DotSetting file, and this setting changes how ReSharper analyzes the code, but alas, this did not take away the compilation errors.

                  How do I enable support in Visual Studio 2017 for the latest version of VB.NET in an ASP.NET Web Site or Web Application project?

                  解决方案

                  To use the latest VB.NET or C# with ASP.NET Web Applications and Web Sites projects you need to install or update two Rosyln Nuget packages.

                  Microsoft:

                  When you have a solution open which has at least one web project which is targetting .NET 4.5+ and does not have the DotNetCompilerPlatform NuGet package in the Project menu you’ll see a new option, Enable C# 6 / VB 14 appear.

                  The following screenshot is from VS2015 but the option should be present in VS2017 too:

                  Alternatively, bypass the above GUI feature and just go directly to the Nuget package manager and install the latest version of the following packages into the project/site to be as up-to-date with the VB.NET language as it is possible to be:

                  • Microsoft.CodeDom.Providers.DotNetCompilerPlatform
                  • Microsoft.Net.Compilers

                  (NB The latest releases are demanding .NET 4.6+ is installed on the system for the compiler to run, but can compile code targeting any platform).

                  This will likely get you sorted for C# 6/VB 14. There is one last step to get VB 15: edit the langversion in the web.config file so that it reads 15.0 (or latest if you want to be on the newest version - this in my preferred option).

                  <system.codedom>
                    <compilers>
                      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
                  type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                  warningLevel="4" compilerOptions="/langversion:15.0 /nowarn:41008 /define:_MYTYPE=&quot;Web&quot; /optionInfer+"/>
                   </compilers>
                  

                  Unfortunately I have found myself having to edit the langversion after upgrading my Roslyn to C# 7.0 and then to 7.1 so it is definitely something to look out for.

                  By the way, this answer doesn't just apply to old projects - even new web projects created in VS 2017 need this fix if the template used doesn't reference the Nuget compiler packages. Roslyn is not mandatory and the template for e.g. a new Web Site has reportedly not been updated.

                  这篇关于如何在 ASP.NET 网站项目中使用最新的 VB.NET 语言级别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  JSON.Net custom contract serialization and Collections(JSON.Net 自定义合约序列化和集合)
                  c# JSON Serialization Use Value Instead of Property Name(c# JSON序列化使用值而不是属性名)
                  Deserialize a Listlt;AbstractClassgt; with newtonsoft.json(反序列化列表lt;AbstractClassgt;使用 newtonsoft.json)
                  Deserialize only one property of a JSON file(仅反序列化 JSON 文件的一个属性)
                  Method not found #39;Void Newtonsoft.Json.Serialization.DefaultContractResolver.set_IgnoreSerializableAttribute(Boolean)(找不到方法无效 Newtonsoft.Json.Serialization.DefaultContractResolver.set_IgnoreSerializableAttribute(Boolean)) - IT屋-
                  Automatically bind pascal case c# model from snake case JSON in WebApi(从 WebApi 中的蛇案例 JSON 自动绑定帕斯卡案例 c# 模型)
                  <i id='SQvPn'><tr id='SQvPn'><dt id='SQvPn'><q id='SQvPn'><span id='SQvPn'><b id='SQvPn'><form id='SQvPn'><ins id='SQvPn'></ins><ul id='SQvPn'></ul><sub id='SQvPn'></sub></form><legend id='SQvPn'></legend><bdo id='SQvPn'><pre id='SQvPn'><center id='SQvPn'></center></pre></bdo></b><th id='SQvPn'></th></span></q></dt></tr></i><div id='SQvPn'><tfoot id='SQvPn'></tfoot><dl id='SQvPn'><fieldset id='SQvPn'></fieldset></dl></div>

                  1. <tfoot id='SQvPn'></tfoot>
                    <legend id='SQvPn'><style id='SQvPn'><dir id='SQvPn'><q id='SQvPn'></q></dir></style></legend>
                  2. <small id='SQvPn'></small><noframes id='SQvPn'>

                          <bdo id='SQvPn'></bdo><ul id='SQvPn'></ul>
                              <tbody id='SQvPn'></tbody>