Chuyển tới nội dung chính

Build Code (C# to DLL) & Invoke Method

Overview​

The Build Code feature allows you to include C# source files (.cs) directly in an akaBot Studio project, compile them into a local assembly (.local\Custom_Code.dll), and invoke custom methods within your workflows using the Invoke Method activity.

Build Code Button in Ribbon


1. Compiling C# Source Files​

Follow these steps to compile your C# code into a usable assembly:

  1. Add C# source files to your project:

    • Create or copy .cs files into your project directory (e.g., JsonDownload.cs).
    • Define your custom classes and public methods (static or instance).

    Project Explorer with CS files

  2. Run Build Code:

    • Click Build Code in the Studio ribbon.
    • Studio compiles all .cs files and generates .local\Custom_Code.dll, updating .local\cache.json.
  3. Restart Studio:

    • A confirmation prompt lists the compiled files and prompts you to restart.
    • Click Restart Studio to reload the project with the new assembly.

Build Code Success and Restart Prompt


2. Invoking Compiled Methods​

After restarting Studio, use the Invoke Method activity (System.Activities.Statements.InvokeMethod) to call your compiled C# methods.

Invoke Method Designer

Configure the following properties:

PropertyDescription
TargetTypeFor static methods: browse and select the compiled C# class (e.g., MyCompany.Helpers.DataProcessor).
TargetObjectFor instance methods: provide the instantiated object variable.
MethodNameThe exact name of the method to invoke (e.g., ProcessInvoice, ComputeHash).
ParametersInput and output arguments matching the C# method signature.
ResultA workflow variable to capture the method's return value.

Invoke Method Properties