Knowledge Base

Start Process From .NET Application - Robot as a WCF Service

Increase your development productivity by taking advantage of our Robot API feature.

Starting with UiPath 8 you can control the execution of processes from your .NET application by integrating it with our WCF service.

Prerequisites: UiPathStudio.msi installed

Let's start by creating a new project in Visual Studio. The sample code presented in this article is developed using Visual Studio 2015, but any other version can be used.

After creating the project, just go in Solution Explorer,  right click on your project's name and select Add service reference. A service reference enables a project to access a Windows Communication Foundation service.

In the Address box, enter the address of UiPath Robot service, net.pipe://localhost/UiPath/service/MEX, and then click Go to search for it.

In the Namespace box, enter the namespace that you want to use for the reference.

Click Ok to add the reference to your project.

A service client (proxy) is generated, and metadata describing the service is added to the app.config file automatically.

All you need to do next is to create a class that handles your duplex communication and you're done. Below you can find a code sample.

[CallbackBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, UseSynchronizationContext = false)]
public class RobotClient : IUiPathRemoteDuplexContractCallback
private IUiPathRemoteDuplexContract Channel = null;
private DuplexChannelFactory<IUiPathRemoteDuplexContract> DuplexChannelFactory = null;
public RobotClient()
DuplexChannelFactory = new DuplexChannelFactory<IUiPathRemoteDuplexContract>(new InstanceContext(this), "DefaultDuplexEndpoint");
DuplexChannelFactory.Credentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
Channel = DuplexChannelFactory.CreateChannel();

Service methods
public Guid StartJob(string serializedJob)
return Guid.Parse(Channel.StartJob(SerializeStringToStream(serializedJob)));

#region Duplex callbacks
void OnJobCompleted(string invokeCompletedInfo)
var settings = new JsonSerializerSettings
TypeNameHandling = TypeNameHandling.None
var completedResult = JsonConvert.DeserializeObject<InvokeCompletedArgs>(invokeCompletedInfo, settings);
if(completedResult.State == System.Activities.ActivityInstanceState.Faulted)
else if(completedResult.State ==  System.Activities.ActivityInstanceState.Canceled)
Console.WriteLine("Process cancelled");
Console.WriteLine("Completed without errors");
#endregion Duplex callback

Main function

class Program
static void Main(string[] args)
var client = new RobotClient();
var job = @"{'WorkflowFile': 'C:\\Workflows\\RobotAPI\\Main.xaml', 'InputArguments': {'Message': 'Message from RobotAPISample'}, 'User': '<username>', 'Type': 0}";

 The complete sample can be dowloaded from here.