Venkat asked here about the possibility to use C# code inside UiPath. The answer from Srinivas links to a post of Andrew about the temporarily removing of C# support. Current status: It is not possible to use C# code with UiPath Studio.
I developed a half year ago for SAP IRPA a library which offers the possibility to execute C# or VB.NET code seamlessly in IRPA, it called dotNETRunner. With Venkats email it comes into my attention that the C# support is temporarily disabled in UiPath Studio. An implementation for UiPath on this basis therefore makes sense now.
Download the package:
dotNETRunner.Activities.1.3.1.nupkg (11.8 KB)
Download the documentation:
dotNETRunner.1.3.1.pdf (305.4 KB)
Install the package:
After the installation you find an activity called dotNetRunner with the property and the two methods:
You can use it very easily:
Read the C# source via Read Text File activity. Here an example of Test.dotNETRunner.cs:
//-Begin----------------------------------------------------------------
using System.Windows.Forms;
namespace Foo {
public class Bar {
public string SayHelloFunc() {
return "Hello World";
}
public int Say42Func() {
return 42;
}
public double Say166Func() {
return 166.0;
}
public int Add(string v1, string v2) {
int val1 = System.Convert.ToInt32(v1);
int val2 = System.Convert.ToInt32(v2);
int res = val1 + val2;
return res;
}
public void Yell() {
MessageBox.Show("Hello World with native dotNET", "C#");
}
}
}
//-End------------------------------------------------------------------
Add the assembly:
Compile the code:
Execute the method SayHelloFunc:
And you will get this result:
Or you can call any other method, e.g. Yell:
With dotNETRunner you can execute C#, VB.NET or JScript methods.
'-Begin-----------------------------------------------------------------
Imports System.Windows.Forms
Namespace Foo
Public Class Bar
Public Function SayHelloFunc() As String
SayHelloFunc = "Hello World"
End Function
Public Function Say42Func() As Integer
Say42Func = 42
End Function
Public Function Say166Func() As Double
Say166Func = 166.0
End Function
Public Function Add(val1 As String, val2 As String) As Integer
Add = CInt(val1) + CInt(val2)
End Function
Public Function Yepp(val1 As String, val2 As String) As String
Yepp = val1 & val2
End Function
Public Sub Yell()
MessageBox.Show("Hello World with native dotNET", "VB.NET")
End Sub
End Class
End Namespace
'-End-------------------------------------------------------------------
Here a JScript example:
//-Begin----------------------------------------------------------------
import System.Windows.Forms;
package Foo {
class Bar {
function SayHelloFunc() {
return "Hello World";
}
function Say42Func() {
return 42;
}
function Say166Func() {
return 166.0;
}
function Add(v1, v2) {
var res = parseInt(v1) + parseInt(v2);
return res;
}
function Yell() {
MessageBox.Show("Hello World with native dotNET", "JScript");
}
}
}
//-End------------------------------------------------------------------
Hope this is a valid alternative until UiPath supports C# again.
My favorite example is the display of Mandelbrot.
Here the code: Mandelbrot.zip (1.5 KB)
Addendum 11.09.2022: The approach presented here is deprecated, because it can’t work in the Windows compatibility mode.