Can we invoke C # code in Uipath

Hi ,
I am trying to invoke some code using uipath 'invoke code 'activity.
Below is my code:
public class services
{
public static void StartService(string serviceName)
{
ServiceController service = new ServiceController(serviceName);
service.Start();
}
}

I am getting below error.
No compiled code to run
error CS1513: } expected At line 0
error CS1022: Type or namespace definition, or end-of-file expected At line 13

Can we do this using uipath ? is there any dependent package to resolve this issue?

Hi
yes invoke code activity can take C#

Cheers @prasanna.Ui

Hi @prasanna.Ui

In the invoke code activity you can select the language
Properties1

Thanks
Anoop

Hi @prasanna.Ui ,

You need to import namespace ‘System.ServiceProcesses’ before invoking code.
Temp.xaml (6.8 KB)

Hope this helps.

still you dont use classes, methods or functions in there…

Hi Lipika,

Thanks .

I have tried in the same but I getting below error could you please help me to resolve this.
Capture
getting below error.
Capture1

Hi @prasanna.Ui,

Check this prerequisites before execution or starting service through code

  1. The service should be present in services.
    image
  2. Right click on the services and from properties fetch the service Name-
    image
  3. In Invoke code-
    image