# Invoke Code Always Fails: Method Not Found

**URL:** <https://forum.uipath.com/t/invoke-code-always-fails-method-not-found/368878>\
**Category:** Activities\
**Tags:** question, studio, system, activities\
**Created:** [December 10, 2021, 6:34pm UTC](https://forum.uipath.com/t/invoke-code-always-fails-method-not-found/368878 "2021-12-10T18:34:32Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![tsverthoff](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/tsverthoff/32/178077_2.png) [@tsverthoff](https://forum.uipath.com/u/tsverthoff)\
**Post date:** [December 10, 2021, 6:34pm UTC](https://forum.uipath.com/t/invoke-code-always-fails-method-not-found/368878/1 "2021-12-10T18:34:33Z")

</div>

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](http://vb.net) and
2. The required namespace is always in the workflow’s namespace list.

Much obliged for any assistance.

---

<div class="post-metadata">

**Author:** ![kirankumar.mahanthi1](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kirankumar.mahanthi1/32/322620_2.png) [@kirankumar.mahanthi1](https://forum.uipath.com/u/kirankumar.mahanthi1)\
**Post date:** [December 10, 2021, 6:42pm UTC](https://forum.uipath.com/t/invoke-code-always-fails-method-not-found/368878/2 "2021-12-10T18:42:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tsverthoff](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/tsverthoff/32/178077_2.png) [@tsverthoff](https://forum.uipath.com/u/tsverthoff)\
**Post date:** [December 10, 2021, 6:47pm UTC](https://forum.uipath.com/t/invoke-code-always-fails-method-not-found/368878/3 "2021-12-10T18:47:07Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![kirankumar.mahanthi1](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kirankumar.mahanthi1/32/322620_2.png) [@kirankumar.mahanthi1](https://forum.uipath.com/u/kirankumar.mahanthi1)\
**Post date:** [December 10, 2021, 6:53pm UTC](https://forum.uipath.com/t/invoke-code-always-fails-method-not-found/368878/4 "2021-12-10T18:53:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tsverthoff](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/tsverthoff/32/178077_2.png) [@tsverthoff](https://forum.uipath.com/u/tsverthoff)\
**Post date:** [December 10, 2021, 7:18pm UTC](https://forum.uipath.com/t/invoke-code-always-fails-method-not-found/368878/5 "2021-12-10T19:18:09Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![kirankumar.mahanthi1](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kirankumar.mahanthi1/32/322620_2.png) [@kirankumar.mahanthi1](https://forum.uipath.com/u/kirankumar.mahanthi1)\
**Post date:** [December 10, 2021, 8:09pm UTC](https://forum.uipath.com/t/invoke-code-always-fails-method-not-found/368878/6 "2021-12-10T20:09:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tsverthoff](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/tsverthoff/32/178077_2.png) [@tsverthoff](https://forum.uipath.com/u/tsverthoff)\
**Post date:** [December 10, 2021, 9:26pm UTC](https://forum.uipath.com/t/invoke-code-always-fails-method-not-found/368878/7 "2021-12-10T21:26:09Z")

</div>

@Kir - I appreciate your help, but:

UIPath.system.activities version 21.4.1

Namespaces in the workflow (after a remove all unused):  
 ![image](https://global.discourse-cdn.com/uipath/original/4X/b/5/0/b5091cb23f1ae24726f177deace71bfc2470f977.png)

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

---

<div class="post-metadata">

**Author:** ![Manan\_Narang](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/manan_narang/32/258417_2.png) [@Manan\_Narang](https://forum.uipath.com/u/Manan_Narang)\
**Post date:** [December 10, 2021, 9:48pm UTC](https://forum.uipath.com/t/invoke-code-always-fails-method-not-found/368878/8 "2021-12-10T21:48:31Z")

</div>

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

> **[About Automation Projects](https://docs.uipath.com/studio/docs/about-automation-projects)**
>
> UiPath Studio enables you to create the following types of projects: Process - Design an automation process and publish it so that it can be executed by robots.Library - Design workflows as reusable components and publish the project as a library...

---

<div class="post-metadata">

**Author:** ![JOJI\_Cherian\_AC\_Kolkata](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/joji_cherian_ac_kolkata/32/265856_2.png) [@JOJI\_Cherian\_AC\_Kolkata](https://forum.uipath.com/u/JOJI_Cherian_AC_Kolkata)\
**Post date:** [January 13, 2022, 3:49pm UTC](https://forum.uipath.com/t/invoke-code-always-fails-method-not-found/368878/9 "2022-01-13T15:49:21Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Anurag\_Singh1](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/anurag_singh1/32/96708_2.png) [@Anurag\_Singh1](https://forum.uipath.com/u/Anurag_Singh1)\
**Post date:** [March 2, 2022, 9:57am UTC](https://forum.uipath.com/t/invoke-code-always-fails-method-not-found/368878/10 "2022-03-02T09:57:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ewanc1](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ewanc1/32/182679_2.png) [@ewanc1](https://forum.uipath.com/u/ewanc1)\
**Post date:** [June 13, 2022, 2:37pm UTC](https://forum.uipath.com/t/invoke-code-always-fails-method-not-found/368878/11 "2022-06-13T14:37:39Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![matteo.tatibouet](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/matteo.tatibouet/32/176617_2.png) [@matteo.tatibouet](https://forum.uipath.com/u/matteo.tatibouet)\
**Post date:** [June 30, 2022, 8:51am UTC](https://forum.uipath.com/t/invoke-code-always-fails-method-not-found/368878/12 "2022-06-30T08:51:57Z")

</div>

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?
