Invoke workflow from coded source file (not from coded workflow)

Is this possible or does it have to be called from a coded workflow?

            var argIn = new Dictionary<string, Object>
            {
         {"assetName", "MyAsset"},
        {"assetValue", "hello world"}
            };

            try
            {
                var result = RunWorkflow("WF.xaml", argIn);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Source);
                Console.WriteLine(e.StackTrace);
                Console.WriteLine(e.Data);
            }

This is the exception I’m getting:

03/20/2024 12:57:00 => [Debug] System.Private.CoreLib
03/20/2024 12:57:00 => [Debug] at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at System.Threading.Tasks.Task`1.get_Result()
   at UiPath.CodedWorkflows.CodedWorkflowBase.RunWorkflow(String workflowFilePath, IDictionary`2 inputArguments, Nullable`1 timeout, Boolean isolated, InvokeTargetSession targetSession)
   at OpenEMicroWeb.RPALib.GetFile(String unParsedXML) in C:\Users\dev.robot\Documents\UiPath\OpenEMicroWeb\RPALib.cs:line 59
03/20/2024 12:57:00 => [Debug] System.Collections.ListDictionaryInternal

Hi Rickard,

The entry point has to be either a coded workflow or a normal workflow, but maybe I’m confused regarding your exact scenario. Normally, RunWorkflow should work just fine for any scenario, unless you are somehow calling it using InvokeCode in XAML.

If you could share a project where this reproduces, we can definitely take a look.

Thanks,
Alvin

I think I missed the main part and that is I’m running it from a coded source file.