# Invoke code activity Error

**URL:** <https://forum.uipath.com/t/invoke-code-activity-error/98031>\
**Category:** Help\
**Tags:** system, activities\
**Created:** [February 26, 2019, 9:23am UTC](https://forum.uipath.com/t/invoke-code-activity-error/98031 "2019-02-26T09:23:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![malam9384](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/malam9384/32/263143_2.png) [@malam9384](https://forum.uipath.com/u/malam9384)\
**Post date:** [February 26, 2019, 9:23am UTC](https://forum.uipath.com/t/invoke-code-activity-error/98031/1 "2019-02-26T09:23:38Z")

</div>

Hello,

I want to create function using with [vb.net](http://vb.net) code in invoke code activity.  
But its give error, please any one help me.

 ![Invoke_Code](https://global.discourse-cdn.com/uipath/original/3X/0/2/020bd224d6703f07309981cac82ae2a6390eb6ec.png)

Module myfunctions  
Function FindMax(ByVal num1 As Integer, ByVal num2 As Integer) As Integer  
’ local variable declaration \*/  
Dim result As Integer

```
  If (num1 > num2) Then
     result = num1
  Else
     result = num2
  End If
  FindMax = result

```

End Function  
Sub Main()  
Dim a As Integer = 100  
Dim b As Integer = 200  
Dim res As Integer

```
  res = FindMax(a, b)
  Console.WriteLine("Max value is :", res)

```

End Sub  
End Module

---

<div class="post-metadata">

**Author:** ![J0ska](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/j0ska/32/111328_2.png) [@J0ska](https://forum.uipath.com/u/J0ska)\
**Post date:** [February 26, 2019, 2:07pm UTC](https://forum.uipath.com/t/invoke-code-activity-error/98031/2 "2019-02-26T14:07:28Z")

</div>

Hi,  
The UiPath documentation is quite brief in InvokeCode activity description ☹  
But I suppose you could not declare Module inside InvokeCode, maybe not even Function, just plain .NET code

Cheers

---

<div class="post-metadata">

**Author:** ![J0ska](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/j0ska/32/111328_2.png) [@J0ska](https://forum.uipath.com/u/J0ska)\
**Post date:** [February 26, 2019, 2:09pm UTC](https://forum.uipath.com/t/invoke-code-activity-error/98031/3 "2019-02-26T14:09:20Z")

</div>

See more here [Invoke code activity VB.Net example](https://forum.uipath.com/t/invoke-code-activity-vb-net-example/10903)

---

<div class="post-metadata">

**Author:** ![redlynx82](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/redlynx82/32/50046_2.png) [@redlynx82](https://forum.uipath.com/u/redlynx82)\
**Post date:** [February 26, 2019, 9:15pm UTC](https://forum.uipath.com/t/invoke-code-activity-error/98031/4 "2019-02-26T21:15:32Z")

</div>

As pointed out by others, there’s no need for a module or function statement, and the `Invoke Code` activity supports neither. However, what you’re trying to do is already part of .NET - no need to reinvent the wheel:

![mathMax](https://global.discourse-cdn.com/uipath/original/3X/4/e/4e10f75a9bceb4f323accd1676bd922988bae97f.png)

---

<div class="post-metadata">

**Author:** ![Masire](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/masire/32/206547_2.png) [@Masire](https://forum.uipath.com/u/Masire)\
**Post date:** [March 15, 2019, 4:26pm UTC](https://forum.uipath.com/t/invoke-code-activity-error/98031/5 "2019-03-15T16:26:26Z")

</div>

Hello @malam9384,

Hope you’re doing well. I think I had the same problem as yours and this is how I figured it out : using Lambda Expressions (please see example here [VB.NET Lambda Expressions - Dot Net Perls](https://www.dotnetperls.com/lambda-vbnet)).

So, to make your FindMax function in UiPath I followed the following steps:

1. Create the variables in UiPath
2. Add the Invoke code activity in a Sequence and edit arguments to create a “bridge” with previously created variables  
 ![image](https://global.discourse-cdn.com/uipath/original/3X/b/9/b91610d02d21b39e7da63f1f4ead5332ba21ad45.png)
3. Create the Lambda Expression doing the job I want  
 ![image](https://global.discourse-cdn.com/uipath/original/3X/c/7/c71d5c6b5287216b8924776a5ab81e1d84e1e3f5.png)
4. That’s all folks!

You’ll find attached the working XAML file for this example [FindMax With Invoke Code.xaml](https://global.discourse-cdn.com/uipath/original/3X/a/1/a1718b25f08dffc99eb89ef0581ca11dd2f58c81.xaml) (5.7 KB).

Regards,  
@Masire

---

<div class="post-metadata">

**Author:** ![donghai](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/donghai/32/181872_2.png) [@donghai](https://forum.uipath.com/u/donghai)\
**Post date:** [February 4, 2020, 7:53am UTC](https://forum.uipath.com/t/invoke-code-activity-error/98031/6 "2020-02-04T07:53:34Z")

</div>

Hi @Masire  
I am faceing the problem that use System.Drawing.Point type in the invoke code activity,but It will be occur errors , do you have solution?  
Like the below post

> [@Missing from Assembly Error Using Invoke Code](https://forum.uipath.com/t/missing-from-assembly-error-using-invoke-code/144259):
>
> Hi all, Wondering if someone has seen this error. I’m using Invoke Code to convert a text file to pdf using Spire.PDF. Weird thing is it actually worked a few times and then started throwing this error. If I’m reading this right, it seems to be an issue with fowarding RectangeF in System.Drawing 2.0.0.0 to version 4.0.0.0 but issues finding that. System.Drawing is in the Imported Namespaces, I’ve tried reordering in xaml file, .net 4.8 is installed, not sure what else to try. Here’s the erro…

I found the docs right now!

> **[Studio](https://docs.uipath.com/studio/standalone/2023.10)**
>
> The UiPath Documentation Portal - the home of all our valuable information. Find here everything you need to guide you in your automation journey in the UiPath ecosystem, from complex installation guides to quick tutorials, to practical business...

But there is no System.Drawing.Point.My God  
How can I do it?

Regards!
