With UiPath, it has become easier to add custom libraries from Orchestrator, UiPath Go, etc., but from the demonstration experiment stage, it is difficult to install Orchestrator or register your own library in UiPath Go. In the first place, it can be difficult to register even the network whitelist.
In this post, I'll show you how to call your own custom library (DLL) directly, not from .nuget.
It's commonplace these days, but in the old days, to create a custom library with UiPath, I had no choice but to create a DLL with Visual Studio and nuget the DLL with Nuget Explorer etc.
Even when debugging with UiPath, there is no Immediate Panel, or even at the moment debugging Com and lambda expressions Could not be analyzed.
This article was created based on the information as of June 2020. The content of the article is my personal opinion, not the official opinion of the organization to which I belong.
For the usage image, the DLL of the custom library is stored in a specific folder (for example, under the project), and I would like to call it from a DLL file, much like invoking an xaml file.
The DLL that can be used in the sample is prepared here. https://github.com/takusonix/UiPathCustomLibrary/raw/master/UiPathCustomLibrary/bin/Release/UiPathCustomLibrary.dll
The source content is here.
using System.Windows;
namespace UiPathCustomLibrary
{
public static class TestClass
{
public static void Test1()
{
MessageBox.Show("Hello World");
}
public static void Test2(string message)
{
MessageBox.Show(message);
}
public static int Test3(int a, int b)
{
return a + b;
}
}
}
You may prepare your own without using the sample DLL.
The UiPath project structure looks like this.
The custom library sample (UiPathCustomLibrary.dll) is stored directly under the project.
Create a variable called ʻasm` in UiPath.
Select Browse for Types ...
as the asm type.
Enter System.Reflection.Assembly
for the Type Name and select Assembly.
Add an Assign activity and set ʻasm` on the left side.
Set the following values on the right side of Assign.
Assembly.LoadFile( _
Path.Combine( _
Environment.CurrentDirectory, _
"UiPathCustomLibrary.dll" _
) _
)
*** You have now loaded the DLL. *** ***
Add a variable for the method to execute
--Namespace (usingName) --Class Name --MethodName
Set the values for each variable.
Add the variable resultObj
to set the execution result and change the variable type to ʻObject`.
Add an Assign that sets the execution and execution result.
Set the value of resultObj to the following value
asm _
.GetType( usingName + "." + className ) _
.GetMethod(methodName) _
.Invoke(Nothing, Nothing)
When executed, the Hello World message will be displayed.
(If the message box is not displayed in the foreground, please select the unnamed task of UiPath Robot from the taskbar as shown in the image.)
In this post, I've only called the method. The Test2 and Test3 methods provided in the sample custom library, argument settings, and execution result acquisition will be posted separately.
If you like, please use LGTM.
Recommended Posts