How to use dotNET Assemblies

There are many many dotNET assemblies available. To use an assembly inside an Invoke Code Activity you can install it in the Global Assembly Cache (GAC) and import it, or you can use it directly, the way I present here.

Let us start with an own tiny assembly. This assembly contains only one function, with the name test. This function has one parameter and delivers a string.


using System;

public class TestLibrary {

  public string Test(string Name = "World") {
    return "Hello " + Name;



We compile this file to a DLL.

c:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe -platform:anycpu -out:TestLibrary.dll -target:library TestLibrary.cs

Copy the assembly TestLibrary.dll into your UiPath project directory. To use the function of this assembly in your Invoke Code Activity it is necessary to do three steps:

  1. Load the assembly with the method LoadFrom.
  2. Get an object that represents the class with GetType.
  3. Create an instance of the class with CreateInstance.

After this steps we can use the function of the assembly in our code.

System.Reflection.Assembly TestLibrary = System.Reflection.Assembly.LoadFrom(@"TestLibrary.dll");
System.Type Class = TestLibrary.GetType("TestLibrary");
dynamic Instance = System.Activator.CreateInstance(Class);

string Result = Instance.Test("Stefan");

Result = Instance.Test();

In this example I try it one time with a parameter and one time without a parameter.


On this way it is possible to use dotNET assemblies directly in the code sequence of the Invoke Code Activity.