This is fantastic, @Jon_Smith.
Thanks a million for sharing. ![]()
Cheers, Emerald.
P.S.: Here’s a suggestion to make the code a bit less cluttered.
// Load the assembly containing the ExecutorRuntime type
var executorDll = System.Reflection.Assembly.Load("UiPath.Executor.Core");
// Get the ExecutorRuntime type from the assembly
var executorType = executorDll.GetType("UiPath.Executor.Core.Api.ExecutorRuntime", true);
// Use reflection to get the `GetExtension` method from the AsyncCodeActivityContext class
var method = typeof(AsyncCodeActivityContext).GetMethod(nameof(System.Activities.AsyncCodeActivityContext.GetExtension));
// Use reflection to make the `GetExtension` method generic and specify the ExecutorRuntime type
var generic = method.MakeGenericMethod(executorType);
// Invoke the `GetExtension` method with the context and no arguments to get the ExecutorRuntime instance
var executor = generic.Invoke(context, null);
// Use reflection to get the WorkflowFilePath property from the ExecutorRuntime instance
var workflowFilePath = (string)executor.GetType()
.GetProperty("UiPath.Robot.Activities.Api.IRunningJobInformation.WorkflowFilePath", BindingFlags.NonPublic | BindingFlags.Instance)
.GetValue(executor);