.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

How to set InArguments for DynamicActivity?

Posted By:      Posted Date: August 31, 2010    Points: 0   Category :Windows Application
Hi. I'm trying to schedule DynamicActivity in my custom activity inherited from NativeActivity. This DymanicActivity is loaded from XAML. I need to set values for its InArguments. All what I can do is: protected override void Execute(NativeActivityContext context) { object inArgExpression = new Literal<string> { Value = someInArgument.Get(context) }; (dynamicActivity.Properties["someInArgument"].Value as InArgument).Expression = inArgExpression as ActivityWithResult; context.ScheduleActivity(dynamicActivity); } but it works only if I know type of InArgument and can choose a corresponding expression type. Unfortunatly it's not what I need. I have trying to use ArgumentToExpressionConverter but it always returns null. And I'm not sure that it is corretly to use it here. Is there another way to set InArguments of DynamicActivity (WorkflowInvoker is not an option)? Thanks a lot.

View Complete Post

More Related Resource Links

Hosted Designer fails to load workflow xaml that has InArguments with default values (xaml saved by

I have hosted the designer in our app. Using the hosted designer, workflows are saved as xaml to a database. When an end user wishes to edit a workflow the xaml is downloaded to a file and loaded into the designer via the .xaml file. The user can also associate assemblies with the workflow and there is a mechanism which makes sure that these assemblies are loaded into the appdomain and available. The problem we are hitting occurs when the top level activity (Sequence) has InArgument with default value. I create a simple Sequence, add InArguments (type of Int32 and String)  and set some default values. I save the workflow xaml to the database and close down the designer. When I wish to edit the workflow and try to load I get the following errors Could not find member '{clr-namespace:}_e905.argument3'. Could not find member '{clr-namespace:}_e905.argument1'. suggesting that some assembly/namespace missing. Here is the xaml I try to load: <Activity mc:Ignorable="sap" x:Class="{x:Null}" this:_e905.argument3="99" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:s="clr-namespace:System;assembly=mscorl

Checking for empty InArguments

I'm new to WF, just getting started on Team Build's build templates, and have a question: what's the best way for telling whether an InArgument is empty because it hasn't been set, or because an empty value has been provided? For instance, I'm writing an Attrib code activity that allows you to set the attributes on a file. If I have a read-only file, and use my Attrib activity to set its Archive attribute, I don't want the ReadOnly attribute being cleared unless I explicitly set its value to False in the activity. I can see this as being possible if I don't use AutoProperties, but does WF have any builtin mechanism for checking whether an InArgument has been set?

Exposing InArguments to child activities

The Scenario:

I have a sequence activity B with InArgument X and I want  child activity Z to be able to use the data passed into InArgument X.

How do I do this?

My current attempt as been to take the value from InArgument X and Place it in a variable that is expected to be there. But I get an exception:

Activity '1: Sequence<String>' cannot access this variable because it is declared at the scope of activity '1: Sequence<String>'.  An activity can only access its own implementation variables.

Current code on my parent sequence where I try to take the value from Argument1 and place it in Variable1

protected override void Execute(NativeActivityContext context)


            var tempVars = _variables.Where(v => v.Name == "Variable1");

            if (tempVars.Count() == 1)


                Variable _inVariable1 = tempVars.First();

                _inVariable1.Set(context, Argument1.Get(context));



            foreach (Activity ac

ActivityBuilder or DynamicActivity for authoring workflow using imperative code


Hi all, 

I'm currently investigating what's the best way to author a workflow using imperative code. I found this link :


but, I'm still curious, which one is better as the main ingredient to author workflow using imperative code, is it ActivityBuilder or DynamicActivity?

The requirement is to write a workflow but we don't need it to be a type. We want to execute the created workflow, as well as perform modification (using code) such as adding/deleting argument, modify the variable, add/delete the sequence etc.

What are the differences between ActivityBuilder and DynamicActivity?


DynamicActivity.Implementation to ActivityBuilder.Implementaiton


As we know that DynamicActivity.Implementaion return Func<System.Activities.Activity> and ActivityBuilder.Implementation returns System.Activities.Activity.

So can we get System.Activities.Activity from Func<System.Activities.Activity> and assign it to ActivityBuilder.Implementaion somehow?




Software Engineer

DynamicActivity cannot reference a variable defined in parent workflow


I have a custom activity that executes a workflow by creating a DynamicActivity instance that is then invoked using WorkflowInvoker.

Prior to invoking the DynamicActivity instance, I set up its Properties using a dictionary of Arguments I have populated using the DynamicArgumentDialog. One of the DynamicActivitiy properties is an out argument and I assign it an an expression that references a variable defined in the parent workflow. The intention of this is that the DynamicActivity workflow will attempt to write a result to the variable defined in the parent.

Here's the code that initialises the Proprerties collection (out arguments only):


 foreach (string argumentKey in Arguments.Keys)
    if (da.Properties.Contains(argumentKey))
     if (da.Properties[argumentKey].Type.GetGenericTypeDefinition().BaseType == typeof(OutArgument))
      da.Properties[argumentKey].Value = Arguments[argumentKey];      

   WorkflowInvoker invoker = new WorkflowInvoker(da);


where Arguments is Dictionary<string, Argument>, populated using DynamicArgumentDialog.

However, when Invoke is called I get the exception:

The following errors were encountered while processing the workflow tree:
'VisualBasicReference<Int32>': Compiler error(s) encountered

Converting DynamicActivity into ActivityBuilder


How can we convert DynamicActivity To ActivityBuilder class?

Please advice.

Software Engineer
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend