Invoking workflow from inside invoke code

Hi,

I’ve been looking for help all over the internet for a couple of hours now.

I found out that the invoke code activity can invoke other workflows with little effort

var settings = new ActivityXamlServicesSettings();
settings.CompileExpressions=true;
var xaml = ActivityXamlServices.Load(@“TestWorkflow2.xaml”,settings);
WorkflowInvoker invoker = new WorkflowInvoker(xaml);
argout=invoker.Invoke(argin,new TimeSpan(0,0,30));

where argout and argin are dictionary<string,object>()

The workflow gets invoked. However, when the invoked workflow enters an application scope, it freezes. The application will boot up (so it enters the scope), but none of the activities inside its scope will be executed. Neither will any activities after the application scope be executed.

Am I missing some settings?
All the other activities inside workflows seem to work, it’s only the application scope that breaks.

Hi @temp_dillen ,

Is it the same case when you invoke the workflow without the Invoke Code Activity as well ?

@temp_dillen You mean Excel Application Scope is getting stuck. Can you share the screenshot of the application scope along with its properties

Hello,

Instead of the code, could you try the Invoke Workflow activity and check whether you are getting the same issue.

Else try to invoke a very simple workflow using script to debug.

Hi!
Thanks for the quick reply.

The workflow works fine with an Invoke workflow file activity.

The test workflow that’s being invoked is a simple ‘use application/browser’ pointing to a blank/new notepad.exe, and then a ‘type into’ with a constant “hello world”.

an Invoke workflow file will produce the desired result. (open notepad → type “hello world” into notepad)
an Invoke code with the for mentioned code will result in the notepad starting but nothing ever gets typed. The invoke code contains an invoke function that takes a timeout, when this timeout expires an exception is thrown (timeout exception as expected) at the invoke code activity.

Hi Rahul,

Thanks for the quick reply.

Any workflow will start executing, and as far as i’ve tested, any activity will work except the use application/browser scope. It won’t execute its child/inner activities and pause until timeout.

It seems like i’m missing something UI related setting/configuration in an object, but i can’t figure out what.

Hello,

Can you create a dummy Wokflow only with some other webpage without much child activities and try to invoke using the invoke Workflow activity.

You can use to open a calculator also for the demo.If its working then you need to check the actual workflow you are trying to invoke. Maybe the exe path of the application.

Hi Ushu,

Thanks for the quick reply,

I mean ‘use application/browser’ activity, its inner scope never executes and a timeout gets thrown in the invoke code activity.

the workflow executes fine using an ‘invoke workflow file’ activity.

I must be missing something in the invoke code

the workflow im testing is a application activity pointing to a blank notepad, and a typeinto actity typing “hello world” into the notepad. I’ve already boiled this down as far as i could to a test case :slight_smile:

@temp_dillen Can you disable type into activity an keep some message just for testing. Now run this snippet and check that message box is executing. Copy this snippet in a different sequence and check the results.

Also tried that! :slight_smile: I replaced the type into with a messagebox activity, a few comments up i sent a screenshot, the “Start - message box” shows, the messagebox inside the application (so the one replacing the type into) never shows, and the 'Stop - message box" also never shows.

Hello,

If possible plz share the Project here. Will try to resolve this.

When you use Invoke Code activity, isn’t it a background thread and therefore you cannot use a foreground activity?

Did you ever find out the cause? I’m trying a similar scenario and stuck at the same point as you are/were.

Best regards
Rickard