.netvb.netredisstring-interpolationinvalid-characters

An interpolation string $ is considered as an invalid character and returns an error BC30037 (vb.net)


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

Solution

  • 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 !!