Invoke Code Always Fails: Method Not Found

Can someone tell me why this fails?

  1. Create a new sequence and add an invoke code activity.
  2. Code:
    Dim testDate As DateTime = #3/12/1999#
    Dim testString As String = FormatDateTime(testDate, DateFormat.LongDate)
  3. According to the Microsoft documentation, FormatDateTime is in the Microsoft.VisualBasic namespace.
  4. Verify that Microsoft.VisualBasic appears in the workflow’s Imported Namespaces list.
  5. Run the file. Output error: method not found

test.xaml: 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)’.

Except for the simplest possible examples, I can never get invoke code to work, even though:

  1. My UIPath is set to use vb.net and
  2. The required namespace is always in the workflow’s namespace list.

Much obliged for any assistance.

Hi,

I have faced the same exception while executing invoke code activity. I have resolved it by downgrading my uipath.system package to lower version from latest. Some how the latest system package is not able to compile the vb code and throwing exception related to syntax tree. Try and let me know. Thanks.

1 Like

@Kir thanks for your reply.

  1. Do you mean the uipath.system.activities package?
  2. Can you tell me what version of the uipath.system.activities package worked for you?

Thank you,
Tom

Hi,

Yes Uipath.system.activities package.

→ latest 2021.10.3 downgrade to 2021.10.2 it should work. for me this package version not giving me any error.

i have little bit confused i have tried with two version 2021.10.2 and 21.4.1 either one of the package version helped me to resolve the issue. try both versions and let me know. thanks.

2 Likes

@Kir - thanks for your help, however:

  1. Uninstall uipath.system.activities 21.10.3.
  2. Reboot UIPath studio.
  3. Install alternate package version.

Using uipath.system.activities 21.10.2
Method not found error; same error as with package version 21.10.3

Using uipath.system.activities 21.4.1
test.xaml: No compiled code to run
error BC30561: ‘DateFormat’ is ambiguous, imported from the namespaces or types ‘UiPath.Excel.Activities.Business, UiPath.Core.Activities, Microsoft.VisualBasic’. At line 2

1 Like

Hi,

I am sure this is related to the method which are trying to use both the Excel and other name spaces that made it ambiguous. Please remove the namespace if you added any new for this invoke code activity. Sure it will work. I think uipath.system.activity 21.4.1 resolve the syntax tree error.

@Kir - I appreciate your help, but:

UIPath.system.activities version 21.4.1

Namespaces in the workflow (after a remove all unused):
image

Error message:
test2.xaml: No compiled code to run
error BC30561: ‘DateFormat’ is ambiguous, imported from the namespaces or types ‘UiPath.Core.Activities, Microsoft.VisualBasic’. At line 2

I’ve tried adding the Microsoft.VisualBasic namespace, but the same error occurs.

-Tom

Hello, please check if the project your created was in vb or c#. Try checking below page:

Hi @kirankumar.mahanthi1 ,
It doesnt work even if I downgrade my UiPath.System.Activities package.
Still populate same error “Method Not Found:Microsoft.CodeAnalysis.SyntaxTree”.
Can anyone help?

1 Like

I was facing the same issue, i did some trial and error by installing different version for UiPath.System.Activities.
For me 21.4.1 works.

I found this had happened to me, and reverting the package back did fix it, unfortunately it broke another activity, so I had to revert it back again. In the same project I found another invoke method that was working. The only difference was the namespace system.security was imported on that workflow. Adding it and closing reopening the broken workflow seemed to fix it. Not sure if that was just a coincidence!

Can confirm that reverting the package version works, but if you’ve already built your project and now need to revert the package, especially a package like UiPath.System.Activities, it’s gonna cause missing activities and it’s a pain. Can’t UiPath fix this problem in their package?

1 Like