Module member declaration expected

Hi Guys,

I’m trying to execute VB.net code in Invoke Code activity. But, it was showing an error “Module member declaration expected”. I see different solutions but i didn’t get any proper one. Please help me to resolve this issue.
This is the code:

   Imports System

Imports System.Collections.Generic
Imports System.Linq
Imports System.Text.RegularExpressions
Imports System.Security.Cryptography

Namespace Rextester
Public Class Program
    Private Sub BuildTheHMACDigest()
        Dim appKeySecret As String = "AKI1598912019031816471634901065"
        Dim epochTime As TimeSpan = (DateTime.UtcNow - New DateTime(1970, 1, 1))
        Dim Data As Long = Convert.ToInt64(epochTime.TotalSeconds)
        Console.WriteLine(Data)
        Dim Encoding As System.Text.ASCIIEncoding = New System.Text.ASCIIEncoding()
        Dim KeyByte As Byte() = Encoding.GetBytes(appKeySecret)
        Dim HMASHA As HMACSHA256 = New HMACSHA256(KeyByte)
        Dim ByteData As Byte() = Encoding.GetBytes(Data.ToString())
        Dim HashedDataOutput As Byte() = HMASHA.ComputeHash(ByteData)
        Dim HashedStringOutPut As String = ByteToString(HashedDataOutput)
        Dim Base64output As String = Convert.ToBase64String(HashedDataOutput)
        Console.WriteLine(Base64output)
    End Sub

  Private Function ByteToString(ByVal buff As Byte()) As String
        Dim sbinary As String = ""

        For i As Integer = 0 To buff.Length - 1
            sbinary += buff(i).ToString("X2")
        Next

        Return (sbinary)
    End Function

    Public Shared Sub Main(ByVal args As String())
        Dim p1 As Program = New Program()
        p1.BuildTheHMACDigest()
    End Sub
End Class

End Namespace

Thanks.

1 Like

Please refer the below post.

https://forum.uipath.com/t/issue-in-invoke-code-example/14721/5?u=vivek_arunagiri