4

I'm setting up a Redis cache server in vb.net, so I started implementing the Redis class in my source code so I could use the class methods later.

I currently have this error: "BC30037: invalid caracter" and I can't resolve it. The error comes from the character "$" in front of my string allowing to normally make string interpolation. Here it doesn't work and on the contrary, this character is considered to be invalid (the compilator doesn't understand that it's an interpolation string and therefore returns an error because).

I found someone who solved the same problem in another topic but he used Team Foundation Server and was working on a Visual Studio project : tfs build server - string interpolation $ Character is not valid

I'm working with Visual Studio 2019 and ASP.NET 4.7.2 but I have no project (my code is as it is in visual studio but it's not in a project).

I would like to know how to solve this problem with my current configuration?

Public Function GetCommand() As String Implements IRedisCommand.GetCommand
    Return $"APPEND {Key} {Value}" //$ is the problem here
End Function
  • 1
    Are you using Option Strict On? If not, there might be some other problem that makes it appear that there is a problem with the `$`. – Andrew Morton May 27 '19 at 16:22
  • 1
    The comment character in vb.net is the single quote not // (that's C#). – Mary May 27 '19 at 16:34
  • `Return "${Key} ${Value}"` Also single line comments are created with `'` and not `//`. Multiline comments do not exist in VB. – IOviSpot May 27 '19 at 16:51
  • "my code is as it is in visual studio but it's not in a project" How do you get to the editor without a project? – Mary May 27 '19 at 16:55
  • I'm just working on the folder containing my source code, and this same folder is hosted on an local IIS server allowing me to see what the site looks like. But since I implemented Redis in my code, I can't access my site anymore because of this error. – antoine zombralis May 27 '19 at 17:19

2 Answers2

6

For anyone else wanting to use the latest features in vb.net like string interpolation, here are the steps I had to take to resolve the BC30037 error:

I should note that the error for me only appeared when running the code locally. When published to a server 2012 running iis 7.5+, things worked just fine.

  1. First, make sure your app is using .Net Framework 4.5.1 or higher.

  2. Next, open the package-manager and run

    PM> Install-Package Microsoft.CodeDom.Providers.DotNetCompilerPlatform
    

    This will setup your web.config to target the latest compiler. I believe this is why it doesn't work locally, but worked on the server.

  3. Finally, run

    PM> update-package -reinstall
    

    This makes sure any previously installed libraries are updated for 4.5.1+

Recompile and run your local debug to validate! Hope that helps someone.

RobC
  • 22,977
  • 20
  • 73
  • 80
mighty_mite
  • 566
  • 4
  • 12
4

I finally found an alternative to the problem: I used the String.Format () method to convert the value of objects into strings according to the specified formats and insert them into another string.

It looks like this now :

Public Function GetCommand() As String Implements IRedisCommand.GetCommand
    Return String.Format("APPEND {0} {1}", Key, Value)
End Function

By the way, thank you for your clarifications concerning the vb comments.

Have a good day !!