Example of using the DLL package
- Updated: 2021/08/10
Example of using the DLL package
Build a very simple DLL that will generate a message. Create a bot to run the DLL.
This topic shows how to create a DLL package. If you do not have Microsoft Visual Studio, download the free Community version from Microsoft Visual Studio Community IDE.
Procedure
Create the DLL package.
-
In Microsoft Visual Studio, create a new class
library that
will generate a file type .dll by using C#.
- Navigate to File > New > Project.
- Search for dll in the Search for templates field.
- Select the C# library option.
-
Configure your project as follows:
- Project name: DemoDLL
- Location: [Any]
- Solution Name: DemoDLL
- Click Create.
-
Copy the following code and replace the contents of class1.cs by
pasting:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DemoDLL { public class CallMe { public string ImHere() { String Reply = "You are now inside the DemoDLL, ImHere function!"; return Reply; } } }
- In Solution Explorer, right-click Class1.cs and rename it to "CallMe.cs".
- Navigate to File > Save All.
-
Navigate to Build > Build Solution.
The output window confirms that the DLL package was successfully created and displays the path to your new DemoDLL.dll package in the Output window. Note the package location, as you will need it later to enter into the bot.
Create a bot to execute the DLL package.
-
Create a bot.
-
On the left panel, click Automation.
A list of available bots and forms is displayed.
- Click Create New > Bot.
- Provide a name for thebot: MyDLLbot
- Enter the folder location: Bots\TaskBotExample
- Click Create and Edit.
-
On the left panel, click Automation.
-
Create a variable:
sReturnedString
: string type. -
Use a DLL > Open
action to load your DLL package.
- From the Actions pane, double-click or drag the DLL > Open action.
- In the DLL:Open, Filepath field, select file type Desktop file and click Browse to find your DLL package. Click Open.
- Click Save.
-
Use a DLL > Run function
action to execute your DLL package.
- Double-click or drag the DLL > Run function action to the last line of the bot.
- Click Get DLL Details.
- Select Desktop file type and then click Browse. Locate your DLL package and click Open.
- Click Next.
- Expand the DemoDLL namespace and select the CallMe function. Select method ImHere and click Apply.
- In the Assign the value to a variable field, select sReturnedString.
-
Use a Message box
action to report what was returned from the DLL bot:
- Double-click or drag the Message box action to the last line of the bot.
- In the Enter the message to display field, type: From the DLL: "$sReturnedString$".
- Click Save.
-
Use the DLL > Close
action to end the DLL session.
- Double-click or drag the DLL > Close action to the last line of the bot.
- Click Save.
-
Click the List tab to view your code in text-only
mode.
Your code should look like this:
Start DLL:Open "C:\myFolder\source\repos\DemoDLL\DemoDLL\bin\Debug\DemoDLL.dll for session "Default" DLL:Run function "ImHere" and store output in variable $sReturnedString$ and session "Default" MessageBox "From the DLL: "$sReturnedString$". DLL:Close session "Default" End
-
Run your bot.
The DLL package returns a message to the bot: From the DLL: "You are now inside the DemoDLL, ImHere function!".