DLL package guide
Load a .NET DLL and call a public static method by name.
Version 2.17.1. Installed versions can differ. Examples are illustrative and not tested.
Prerequisites
Use a .NET DLL, not a native C or C++ DLL. Load trusted code only: it runs with the automation's permissions. Put private DLL dependencies beside it; the runtime must have the others.
Use Open, Run function, then Close in cleanup. A relative path starts in the Run folder. The main file is read into memory, so you can replace it while open.
For the example, build samples/ExampleTools.dll with public class ExampleTools.Calculator and public static int Add(int a, int b) => a + b;. Avoid methods with the same name and parameter count. The first found is called, without a type check.
Shared fields
Session
| Field ID | Name in editor | Type; default | Use |
|---|---|---|---|
session | Session name | Stringdefault Defaultoptional | The name that joins Open, Run function and Close, for example Tools. A session does not carry over to another Run. |
Actions
Close (dllClose)
Close the DLL session.
Inputs
Uses the session field.
Outputs
No outputs.
Example
After Open and Run function with session=Tools, set session=Tools in Close.
Expected result
The session closes. The DLL unloads when no code uses it. Run function with Tools fails until reopened. Closing a session that is not open fails.
Open (dllOpen)
Load a .NET DLL. Give each open DLL its own session name.
Inputs
Uses the session field.
| Field ID | Name in editor | Type; default; requirement | Use |
|---|---|---|---|
dll | DLL file path | Stringdefault emptyrequired | An existing .NET DLL, such as samples/. A relative path starts in the Run folder. |
Outputs
| Output | Type | Meaning |
|---|---|---|
session | String | The session name. Bind it to tools to use $tools in later session fields. |
Example
Build the example DLL. Set session=Tools and dllFilePath=samples/ExampleTools.dll. Bind sessionName to String variable toolsSession. Close Tools before opening another DLL with that name.
Expected result
toolsSession is Tools, and Run function can use the DLL. An empty or missing file, a file that is not a .NET DLL, or a missing dependency fails. Open does not check the methods in advance.
Run function (dllRunFunction)
Call a public static method and get its result as text.
Inputs
Uses the session field.
| Field ID | Name in editor | Type; default; requirement | Use |
|---|---|---|---|
class | Class name | Stringdefault emptyrequired | The full class name, such as Example. Case does not matter. The namespace is needed. |
function | Function name | Stringdefault emptyrequired | The exact public static method name, such as Add. Case matters. |
input | Parameters | Listdefault emptyoptional | Text values, one per parameter, in order, such as ["2",. The count must match. Only simple types work (text, numbers, true/false, enum names in any case). Use . as the decimal point. Empty text becomes null only for a nullable parameter. The action does not build objects or arrays, and it does not wait for an async method. |
Outputs
| Output | Type | Meaning |
|---|---|---|
result | String | The return value as text. Bind to sum. Convert number text before a Number field. |
Example
Open the example DLL as Tools. Set session=Tools, className=ExampleTools.Calculator, functionName=Add, and inputParameters=["2","40"]. Bind result to String variable sumText.
Expected result
sumText is the text 42. A Boolean result becomes true or false, a number uses . as the decimal point, and a void or null result becomes empty text. A missing session, class or method, a wrong parameter count, a value that does not convert, or an error in the method fails the step.