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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Dynamic workflow with While activity

Posted By:      Posted Date: August 30, 2010    Points: 0   Category :WPF
We have a very strange problem with WWF 3.5. All our workflows are loaded dynamically, i.e we have different  assemblies containing libraries of the workflows. We starting each workflow by specifying path to assembly and name of the workflow class in the assembly:     Assembly  workflowAssembly = Assembly.LoadFrom(path);     Type  workflowType = workflowAssembly.GetType(name ); We are creating work flow instance as following and execute starts:     WorkflowInstance instance =     workflowRuntime.CreateWorkflow(workflowType, dictParameters);      instance.Start(); Everything works just fine till it hits the While activity. Here workflow is terminated because of the exceptions. Interesting thing is that exceptions here are different depending on what work flow is doing. In case when loop execute sequence activity containing just code activity which increasing some index by 1 each iteration (what could be simpler!) exception is, providing as part of the WorkflowTerminatedEventArgs e: Exception    {"Error binding to target method."}    System.Exception {System.Runtime.Serialization.SerializationException}   When our assembly containing workflows has name  "TestLibPghWWF" and inside While activity, the sequence activity contains real,&

View Complete Post

More Related Resource Links

How to Cancel a Workflow Activity - LogToHistoryListActivity


How can I cancel a LogToHistoryListActivity? I don't understand how to get access to the ActivityExecutionContext. I guess one way is to add an IfElse before entry to avoid the activity completely. Casting the sender object does not work. Help anyone?

  private void logToHistoryListActivity_WorkflowActivated_MethodInvoking(object sender, EventArgs e)
   LogToHistoryListActivity log = (LogToHistoryListActivity)sender;
   string msg = string.Format("Work Request has been SAVED by {0}. Awaiting submittal.", workflowProperties.Originator);
   WFHelper.LogMessageToHistoryList(log, msg, null);

TFS 2010:Testing Workflow 4.0 activity

Hi EveryOne, Is there any way to test the workflow activity with out queing the new build?Usually while working with TFS2008, we ll test the particular class  through console application by passing parameters. In TFS 2010 ,i need to test the workflow ?is there any way some thing like creating an object for workflow and calling through console application? Please  suggest me. Thanks & Regards, eswar reddy 

Sequential Workflow project unable to compile referencing x64 Workflow Activity Library

Folks -   I have an sequential workflow project targeting x64 that will not compile if the workflow activity library that it references is compiled for x64 (it will compile if the activity library targets x86).  The compile error I receive is: Compilation failed. Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. [project name]   Any thoughts on how to figure this out?   Thanks.

Custom sequence activity deriving from System.Workflow.Activities.SequenceActivity

Hi, I try to create custom sequence activity. I found some sample (http://social.msdn.microsoft.com/Forums/en-US/wfprerelease/thread/f54e8eb2-29d9-46f6-ad96-766fe6fad333/). But this custom activity looks ugly (to separate nested activity using ellipses instead of arrows). My question is - how to create custom sequence activity, which will look like sequence activity. I also found this sample - <ContentPresenter x:Uid="ContentPresenter_1" Content="{Binding}" Style="{x:Static sacdt:DesignerStylesDictionary.SequenceStyle}"/> When I used this ContentPresenter my custom activity looks like System.Workflow.Activities.SequenceActivity, but I couldn't put on it another activity. I also created class, which derives from System.Workflow.Activities.SequenceActivity, but I couldn't see it in toolbox. My question is - how to create class, which derives from System.Workflow.Activities.SequenceActivity and is visible in toolbox or how to use ContentPresenter for sequence activity, which allows put on itself another activity.

Workflow 3.5 Activity property is null in condition and nowhere else

I have an activity that has properties that look something like this (they're set up as proper dependency properties, I just kept it simple here): public List<MyType> TypeList { get; set; }public Int32 Index { get; set; }public MyType SelectedType { get; set; } and an execution that just does this: SelectedType = TypeList[Index]; TypeList and Index are values that I set from other activities. I don't set SelectedType to anything in the activity properties, I just let it get set in the execution. Now I know for a fact that SelectedType is getting set properly, I can even point another activity to it and print out some values from it. So I'm quite positive that there's nothing wrong with that activity. However, I have an if activity with a condition that looks like this: ((MyActivity)GetActivityByName("activity1")).SelectedType != null and it evaluates to false (meaning it evaluated SelectedType as null). I'm pretty sure that that activity cast is correct (I do things like that all the time), and if it weren't wouldn't I get a null reference exception when trying to access SelectedType? So I'm pretty sure I'm not doing anything wrong here, but for some reason SelectedType is coming up null in that condition and no where else. It's almost as if the condition is being evaluated before the activity is being run, but the activity comes well before the condi

Display XAML workflow image in browser and hightlight the current Activity

I have a requirement in project to display the XAML workflow in browser as image like the Visual studio designer displaying and it should Hightlight the current activity in workflow.  Please guide me on this.rajeevkalyan

Windows Workflow : Activity Binding Properties Window Ellipses button not visible for one property

I have created a custom activity, when I am using this activity in workflow designer I am not getting the ellipsis button to select a property.  I am getting the ellipses button for first property LongValue while not getting the option for "NavigationUrl" property. This is the code for my custom activity. public partial class SetLongAsResult: Activity {         public SetLongAsResult() { InitializeComponent(); }         public static DependencyProperty LongValueProperty = DependencyProperty.Register("LongValue", typeof(long), typeof(SetLongAsResult));           public static DependencyProperty NavigationUrlProperty = DependencyProperty.Register("NavigationUrl", typeof(string), typeof(SetLongAsResult));           [Description("long value to be returned")]         [Category("Set Result Data")]         [BrowsableAttribute(true)]         [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]         public long LongValue         {             get             {         

Passing a reference of the workflow to an activity

It there a way to pass in a reference of a workflow into an activity that the workflow is running (as an inargument)  in the Workflow designer?

Disable an activity in Designer at run time in workflow 4.0

There are couple of activities in my workflow & based on some condition, I need to make an activity disabled i.e. I don't want that activity to be seletable by the user. I am opening my workflow in designer at run time to give an overview of WF to the user. Something like  (new DesignerMetadata()).Register(); this.wd = new System.Activities.Presentation.WorkflowDesigner(); this.designerSection.Child = (this.wd.View); I was going thru the MS sample of CommentOut Activity but that won't solve my requirement as Activity needs to be disabled at run time based on some condition.

Delay Activity is not working with SharePoint state machine workflow

Hello,   I have a problem with Delay Activity in Sharepoint state machine workflow. This issue is kind of common to many people but so far I haven't come accross any working solution. In one of the workflow states, I want to add a delay activity to send email notification if no action is taken after certain time. Below is what I have done:   In the targeted state: 1) add one eventDriven activity to handle the normal process (approve the item) 2) add another eventDriven activity to send the reminder email. In this eventDriven activity, I first add a delayActivity, set it to 2 minutes for test purpose. Then I add a Sharepoint SentEmail activity.   With my test, the Dealy Activity is never invoked after timeout period. What should I do to make the delay activity work in the SharePoint state machine workflow? Is there any work around if the delay activity is simply not working there?   Any suggestions are appreciated.

Workflow Service 4.0 with One Way Receive activity will not get fired when called by a console based

Workflow Service 4.0 with One Way Receive activity will not get fired when called by a console based client application. This service does get called when there's the default ReceiveRequest coupled with a SendReply activity in the service. However deleting the ReceiveRequest and SendReply Activities and replacing it with a one way Receive Activity causes the Workflow 4.0 Service to not get called. Thanks, Leo Cono - http://www.YouLoveMe.com, Free Dating Site  

Custom Workflow Activity dependency property FieldNames

I have a custom actvity in VS2008. All is well until I added a new dependancy property like so: public static DependencyProperty EventLookupColumnNameProperty = DependencyProperty.Register("EventLookupColumnName",typeof(string),typeof(FTFSyncEventToAttachmentListItem)); public static DependencyProperty EventLookupColumnIDProperty = DependencyProperty.Register("EventLookupColumnID",typeof(string),typeof(FTFSyncEventToAttachmentListItem)); [Description("Event Lookup Column Name")][DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)][Browsable(true)][ValidationOption(ValidationOption.Required)]public string EventLookupColumnName{get { return ((string)(base.GetValue(EventLookupColumnNameProperty))); }set { base.SetValue(EventLookupColumnNameProperty, value); } [Description("Event Lookup Column ID")][ValidationOption(ValidationOption.Required)][Browsable(true)][DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]public int EventLookupColumnID{get { return ((int)(base.GetValue(EventLookupColumnIDProperty))); }set { base.SetValue(EventLookupColumnIDProperty, value); }}Then in the actions file:    <Action Name="FTF Sync Event To Attachment List Item"   ClassName="DP.Sharepoint.Workflow.FTFSyncEventToAttachmentListItem"   Assembly="DP.Sharepoint.Workflow, Version=, Cultur

Workflow switch case activity splitter

Hi All, Can anyone advise, if the switch case activity accept case splitter?  If yes, how? Example: switch (number) Case 1, 5: Kindly advise.

Flowchart workflow, custom "FlowDecision" activity?

Dear all, in order to simplify the workflow "design" we would like to build our own activities that return a result with one or more nodes. Something like the "True/False" nodes that come out of the FlowDecision Activity. I know that one could normally add a FlowDecision activity after our custom activity and insert the condition expression to redirect the flow based on the result... however this requires the ability to know the "content" of the previous activity, and for some users we're targeting it's not immediate. Thank you!Adriano

System.ArgumentException : The input workflow type must be an Activity.


Hi everyone! I’m getting this error when starting up the workflow:

System.ArgumentException : The input workflow type must be an Activity.
Parameter name: workflowType

The code I’m using is shown below:

using (var wf = new WorkflowRuntime())
  wf.WorkflowCompleted += (_, __) => signal.Set();
  wf.WorkflowTerminated += (_, __) => signal.Set();
  var args = new Dictionary<stringobject>();
  args.Add("Input", plainText);
  var inst = wf.CreateWorkflow(typeof (HtmlTypography), args

Exception escapes from workflow despite TryCatch activity


I have a workflow inside a Windows Service that is a loop that performs work periodically. The work is done inside a TryCatch activity. The Try property is a TransactionScope activity that wraps some custom activities that read and update a database. When the transaction fails, I would expect any exception that caused this to be caught by the TryCatch. However, my workflow aborts. The workflow I have is the following:

var wf = new While(true)
  Body = new Sequence
    Activities =
      new TryCatch
        Try = new TransactionScope
          IsolationLevel = IsolationLevel.ReadCommitted,
          Body = new Sequence
            Activities = { ..custome database activities.. }
          AbortInstanceOnTransactionFailure = false
        Catches =
          new Catch<Exception>
            Action = new ActivityAction<Exception>
              Argument = exception,

Dynamic Activity calling CLR Activity fails when Invoked?


MyActivity.xaml has a child activity, a CLR AsyncCodeActivity, SendMail.cs, dragged and dropped onto the 'root' activity which is a FlowChart.   SendMail.cs is in the same directory as MyActivity.xaml which is loaded dynamically like so:

    dynamicallyLoadedActivity = ActivityXamlServices.Load("("..\..\..\MyActivities\MyActivity.xaml");

At runtime, when WorkflowInvoker.Invoke(dynamicallyLoadedActivity ) is called, this exception is thrown:

    XamlObjectWriterException: Cannot create unknown type {"Cannot create unknown type '{clr-namespace:MyApp.MyActivities}SendEmail'."}

The imports on MyActivty.xaml include "MyApp"  xmlns:local="clr-namespace:MyApp.MyActivities"  and the xaml: <local:SendEmail .... looks OK.

Here is the top of the stack trace:

System.Xaml.XamlObjectWriterException was unhandled
  Message=Cannot create unknown type '{clr-namespace:MyApp.MyActivities}SendEmail'.
       at System.Xaml.XamlObjectWriter.WriteStartObject(XamlType xamlType)
       at System.Xaml.XamlWriter.WriteNode(XamlReader reader)

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