Read and Review Automation Anywhere Documentation

Automation 360

Close Contents

Contents

Open Contents

Example of using the DLL package

  • Updated: 8/19/2021

    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.

    1. In Microsoft Visual Studio, create a new class library that will generate a file type .dll by using C#.
      1. Navigate to File > New > Project.
      2. Search for dll in the Search for templates field.
      3. Select the C# library option.
      4. Configure your project as follows:
        • Project name: DemoDLL
        • Location: [Any]
        • Solution Name: DemoDLL
      5. Click Create.
      6. 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;
                }
            }
        }
      7. In Solution Explorer, right-click Class1.cs and rename it to "CallMe.cs".
      8. Navigate to File > Save All.
      9. 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.

    1. Create a bot.
      1. On the left panel, click Automation.
        A list of available bots and forms is displayed.
      2. Click Create New > Bot.
      3. Provide a name for thebot: MyDLLbot
      4. Enter the folder location: Bots\TaskBotExample
      5. Click Create and Edit.
    2. Create a variable: sReturnedString: string type.
    3. Use a DLL > Open action to load your DLL package.
      1. From the Actions pane, double-click or drag the DLL > Open action.
      2. In the DLL:Open, Filepath field, select file type Desktop file and click Browse to find your DLL package. Click Open.
      3. Click Save.
    4. Use a DLL > Run function action to execute your DLL package.
      1. Double-click or drag the DLL > Run function action to the last line of the bot.
      2. Click Get DLL Details.
      3. Select Desktop file type and then click Browse. Locate your DLL package and click Open.
      4. Click Next.
      5. Expand the DemoDLL namespace and select the CallMe function. Select method ImHere and click Apply.
      6. In the Assign the value to a variable field, select sReturnedString.
    5. Use a Message box action to report what was returned from the DLL bot:
      1. Double-click or drag the Message box action to the last line of the bot.
      2. In the Enter the message to display field, type: From the DLL: "$sReturnedString$".
    6. Click Save.
    7. Use the DLL > Close action to end the DLL session.
      1. Double-click or drag the DLL > Close action to the last line of the bot.
    8. Click Save.
    9. 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
    10. Run your bot.
      The DLL package returns a message to the bot: From the DLL: "You are now inside the DemoDLL, ImHere function!".
    Send Feedback