Method Not Found for Invoke Code

Can someone please explain this error?

Method not found: ‘Microsoft.CodeAnalysis.SyntaxTree Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxTree.ParseText(System.String, Microsoft.CodeAnalysis.VisualBasic.VisualBasicParseOptions, System.String, System.Text.Encoding, System.Collections.Immutable.ImmutableDictionary`2<System.String,Microsoft.CodeAnalysis.ReportDiagnostic>, System.Threading.CancellationToken)’.

I am receiving this error on an Invoke Code activity that runs a few lines of VB.Net code. This error does not appear on the master branch of this project but it does appear on a feature branch that I am working on.

I have tried to import the namespaces that are available, I’ve tried to add “Microsoft.Office.Interop.Excel” as a dependency, and I’ve tried to edit the Main.xaml file through notepad by adding a few lines. Nothing has worked

Any other ideas? Thank you

Hi @jpreziuso,

Can you post your code?

Regards
JM

Dim sAux() As String = FirstName.Split(""""c)

If sAux.Length = 3 Then
result = sAux(1)
Else
result = “”
End If

This is the code. I don’t believe I wrote it, I think I found it somewhere

@jpreziuso

I believe your issue is that you have 4 double quotation marks. Try the following code:

Dim sAux() As String = FirstName.Split("""c)

If sAux.Length = 3 Then
result = sAux(1)
Else
result = “”
End If

Regards
JM

Hi @joergen_moeller,

I don’t think the quotes were the issue. I removed the one set of quotes and it still shows an error. It seems to be more of an issue with the namespaces/imports/methods for some reason.

I ran your code without error in a fresh VB.net project with the following dependencies:

image

The arguments in the Invoke Code activity:

Studio version 2022.4.3

I hope this helps you resolve the issue.

JM

Hi,

Which version of Studio and UiPath.System.Activities package do you use?

There is restriction for InvokeCode regarding version. So, can you try to downgrade it to 20.10?

Regards,

I am using Studio version 2020.10.12 and UiPath.System.Activities version 22.4.1.

I downgraded UiPath.System.Activities to version 21.10.4 but it did make the error go away

Hi @jpreziuso ,

Was the Invoke Code Activity copied from other Project or Have you used the Invoke Code Activity and copied the vb.net code to it ?

Hi @supermanPunch,

I had this Invoke Code activity in the master branch of one of my projects. When I split off and copied to the code to a new feature branch, this invoke code activity no longer worked and had an error