locked
ASP.Net Not Recognizing VB 14 Features Such As String Interpolation RRS feed

  • Question

  • User137160187 posted

    Hi,

    I have the latest version of Visual Studio 2017 installed and was trying to use the new "NameOf" function as well as String Interpolation but get the following error message:

    "Visual Basic 12.0 does not support string interpolation"

    I googled this error and found this answer in this forum:

    ---- begin ----
    Found the answer here if anyone else has the same problem. It looks like the Roslyn compiler for Web Site project types is not icluded with VS2015 and must be downloaded separately. See: http://blogs.msdn.com/b/webdev/archive/2014/05/12/enabling-the-net-compiler-platform-roslyn-in-asp-net-applications.aspx
    ---- end -----

    I went to the above URL and did #2:

    Install the new CodeDOM Providers for .NET Compiler Platform (“Roslyn”) NuGet package into your ASP.NET application.

    However, I have no idea how to do #1:

    1. Install the .NET Compiler Platform (“Roslyn”) End User Preview on your developer machine (where you use Visual Studio or build your application’s project file)

    It takes me to the github site where i can download all the source code. I've never used github before but went ahead and downloaded the source code and tried to compile it but hit numerous errors.

    What I was really looking for was a simple executable that I could run and install whatever needs to be installed.

    Can someone please reply with step-by-step instructions on how I can get Rosyln for DotNet installed?

    **** UPDATE: Strangely, my WebSite project compiles and publishes to the web server fine. Also, the webpage with String Interpolation actually works perfectly when published to the live server. However, the PROBLEM is that Visual Studio 2017 is underlining string interpolation as an error in the code editor. 

    So, in a nutshell, the string interpolation is actually WORKING but the Visual Studio 2017 is flagging the code in the editor window as containing an error.

    What do I do?

    Many thanks,

    Matthew

    Wednesday, May 16, 2018 5:38 AM

All replies

  • User283571144 posted

    Hi MatthewNYC,

    According to your description, I have created a test demo on my side, it works well.

    My test codes:

       Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Label1.Text = NameOf(Session)
        End Sub

    Result:

    As far as I know, the VB.NET compiler has the /langversion option for change the vb version.

    I suggest you could firstly unload your project and open the .vbproj file.

    Then you could check the vbproj file to delete below setting.

      <PropertyGroup>
         <LangVersion>12</LangVersion>
      </PropertyGroup>

    Best Regards,

    Brando

    Thursday, May 17, 2018 7:46 AM