.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

WorkFlowApplication vs WorkflowServiceHost

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :JQuery

  What is the difference between workflowapplication invoked workflow and  workflowservicehost invoked workflow. I Know that if the workflow is hosted as service we use workflowservicehost . Please let me know some of the scenarios where we have to use either of these.

 In my case as per the functionality, By using the WWF  if some event is happened I have to create a manual task through workflow and I have to wait for certain event happens or for expiry of time. if time is expired I have to send a notification. Which of the above approach is appropriate to achieve this?

Further even if use the Workflow application object through normal WCF also we can achieve the same functionality like WorkflowService. Any thoughts.


View Complete Post

More Related Resource Links

Confused over whether to use WorkflowApplication or WorkflowServiceHost for wcf activated long runni


I appear to want the best of both worlds between hosting a workflow using WorkflowApplication or WorkflowServiceHost.

I want to instantiate the same workflow multiple times for different datasets via wcf; which leans towards using a WorkflowServiceHost.

However I want the ability to pause a workflow, then resume at some later date once some condition has been met; all the examples for this use the WorkflowApplication type for hosting.

I might be taking the wrong approach, but my idea is for some client to make a service call passing in an id that will also be used as a message correlation key.

The workflow will include a number of validation steps, any of which could fail. Upon failure, I want the service to pause, whilst the underlying (data) issue is fixed.

Once fixed, the client makes the same call to the service and workflow resumes.



Instance scope for WorkflowApplication and extensions

Hi guys,   The documentation isn't quite clear on the instance scope of WorkflowApplication and related extensions. As far as I can tell, a WorkflowApplication can only be used to run a workflow once. It can't be reused to run the workflow any subsequent times. If this is the case, any extensions used in the WorkflowApplication instance are then scoped to that run of the workflow. Is this correct? Cheers

WorkflowApplication Methods Differences?

Can any one explain what the difference is between the following methods of WorkflowApplication: Abort Cancel Terminate

'Completed' is not an event of 'System.Activities.WorkflowApplication'

Hello,I have a C# code which i have converted into VB.But i am getting compile error in VB code:'Completed' is not an event of 'System.Activities.WorkflowApplication'find below C# and VB code:C#:application.Completed += delegate(WorkflowApplicationCompletedEventArgs e){completedEvent.Set();};VB : AddHandler PickSample.application.Completed, Sub(e As WorkflowApplicationCompletedEventArgs) completedEvent.Set()Can some one provide me solution ?

WorkflowApplication.Unloaded is invoked but RunnableInstancesTable is empty

Hi there, I am fresh to WF 4.0 and I encountered a strange issue. My application uses a custom activity to read user's input, and it should be unloaded when it was idle:             WorkflowApplication wfApplication = new WorkflowApplication(new DemoActivity());             wfApplication.InstanceStore = SetupInstanceStore();             // Returning IdleAction.Unload instructs the WorkflowApplication to             // persists application state and remove it from memory.             wfApplication.PersistableIdle = e =>             {                 Console.WriteLine("[DemoActivity]: Yes, unload me!");                 return PersistableIdleAction.Unload;             };             wfApplication.Unloaded = e =>           &nb

WorkflowServiceHost and reactivation of idle instances


I'm having difficulties reactivation instances containing a custom NativeActivity after my WorkflowServiceHost application has been restarted. If i define a workflow containing:


..and restart my application, instances that were waiting for the Delay activity are automatically resumed from the store. However, if i replace the Delay activity, with my WaitForCustomEvent activity, the instances are not resumed when i restart my application. My WaitForCustomEvent is defined like this:

    public sealed class WaitForCustomEntityEvent : NativeActivity
        private void BookmarkResumed(NativeActivityContext context, Bookmark bookmark, object value)
            Debug.WriteLine(String.Format("Bookmark {0} has been resumed", bookmark.Name));

        protected override void CacheMetadata(NativeActivityMetadata metadata)

                    () => new WaitForCustomEntityEventWorkflowExtension());

        protected override void Execute(NativeActivityContext context)
            var bookmark = context.Cre

How to get/set InstanceID [InstanceStore][InstancesTable][Id] using WorkflowServiceHost


Hi folks

I've a solution with a long time running Workflow .xamlx hosted by WorkflowServiceHost. Know I should be able to get or set the InstanceID from the InstanceStore DB. I've no clue about, I read it could be done by extensions but I think thats only solution for Workflows hosted by WorkflowApplication? Do have anyone a good idea, hint? Workflow is using several RecieveAndSendReply Messages.

Thx to help ansering my question.

WindowsApplication executing two WorkflowApplication instances within one transaction



Let's assume we would like to have a WindowsApplication which should be executing two WorkflowApplication instances within one transaction.


We could imagine a button click event handler which should:

  1. Start the transaction.
  2. Execute WorkflowApplication1.
  3. Execute WorkflowApplication2.
  4. Commit the transaction.

Should I just create a TransactionScope and somehow pass it to the WorkflowApplications? If yes, how to pass the TransactionScope to the WorkflowApplications, must this be done explicitly or is it done implicitly?



Best regards,

Henrik Dahl


WorkflowServiceHost ContractFilter mismatch


I have an issue trying to host a WorkFlow Service loaded from XAMLX from a Database. When I try to call one of its Operations I get this exception:

The message with Action 'http://tempuri.org/ISubmitService/Start' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver.  Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).


  Here is code similar to what I’m trying to run:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ServiceModel;
using System.Xml;
using System.Xml.Linq;
using System.IO;
using InsTech.EverGreen.Acord;
using System.ServiceModel.Activitie

Unable to have a WorkflowServiceHostFactory & WorkflowServiceHost for a WF with a XAMLX definition h


I'm hosting my XAMLX WF in IIS/WAS and I need to create a custom host & custom host factory to be able to use a DataContractResolver (http://blogs.msdn.com/youssefm/archive/2009/06/05/introducing-a-new-datacontractserializer-feature-the-datacontractresolver.aspx). I've already take a look at the post mentioned in this link http://social.msdn.microsoft.com/Forums/en-NZ/wfprerelease/thread/bcdef4a1-008c-46f5-b988-a934e8336302 wich describes the same situation. I've also take a look at the links mentioned in the answer to this post.

Nevertheless, I still can't have this scenario working. My scenario is:

1. Have XAMLX WF hosted in IIS/WAS that starts with:

<WorkflowService ConfigurationName="DecisionEngineServiceConfiguration" Name="DecisionEngineService" ...

2a. I've created the .svc file with the following contents:

<%@ ServiceHost Language="C#" Debug="true" Service="DecisionEngineServiceConfiguration" Factory="DecisionEngine.Core.ServiceModel.ServiceHostFactory"

How To Reload a Persisted Workflow with WorkflowServiceHost


We are using Workflow Foundation 4 Beta 2 with a client / server architecture where the client runs workflow through the server  using a WorkflowServiceHost. The client itself runs no workflow. The workflow is long running, requiring that it persist while awaiting user input. We have set up correlation and persistence such that the user can successfully move the workflow from one activity to another. The problem occurs when the workflow is unloaded or the server application is restarted; we are unable to determine how to continue a workflow that has been unloaded. We have looked at numerous samples such as the Hiring Request Process (http://msdn.microsoft.com/en-us/library/ee622985(VS.100).aspx) and the samples demonstrate the same issue…everything works great until the workflows are unloaded or the server (application running the workflowservicehost) is restarted. There is no exception thrown by the client call, the workflow simply doesn’t move forward.

Loading persisted workflow instances with WorkflowApplication


I understand I may be doing this wrong.  I read the topic at http://social.msdn.microsoft.com/Forums/en-CA/wfprerelease/thread/a11eb75d-65de-4787-9745-2fd634d0eee9 but I still don't get it, exactly.

I have an application that uses WorkflowApplications to handle the workflows.  I have a workflow that contains a one minute Delay activity.  When this activity is hit, the workflow Idles, persists (SqlWorkflowDataStore), and unloads.  This is all fine.  If the app runs for the minute, it will be resumed and will complete.

However, if I stop the app during the minute that it is delayed, and then start it up again at some point later, the workflows do not resume.  A little digging shows that WorkflowApplication does not resume automatically, and that I have to do that manually.  That's fine.  The problem is, I don't know how.

I see there is a WorkflowApplication.LoadRunnableInstance, and I see in the db that there are records in the RunnableInstancesTable table.  But when I call LRI, I get back this:

System.Runtime.DurableInstancing.InstancePersistenceCommandException was unhandled
  Message=In order to match and load a runnable instance in the store, the requesting InstanceOwner must have specified a workflow host type when it was created. To do so, add a key-value pair to the CreateWorkflowOwner

WorkflowServiceHost, multiple services and the WorkflowRuntime






I am hosting the workflow runtime in a windows form application to run a number of "standard" WF workflows. I now want to add a number of WorkflowServices. I intend to create a WorkflowServiceHost to host my services.


I noticed a post from Tom Lake that each WorkflowServiceHost can only host a single workflow service (http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2233752&SiteID=1).


Also, I observe that it is posible to get a reference to the runtime being used by the service host by writing code like:


WorkflowRuntimeBehavior workflowRuntimeBehaviour = host.Description.Behaviors.Find<WorkflowRuntimeBehavior>();

WorkflowRuntime rt = workflowRuntimeBehaviour.WorkflowRuntime;


My question is - how many runtimes must I have? Can my standard workflows and each hosted service all sh

System.Runtime.Persistence.InstanceOwnerException causing WorkflowServiceHost Instability

I have a Windows Service running about 7 workflow service hosts, which are obviously hosting Workflow Services.  90% of the time they work fine, but randomly the services seem to fault.  I've had to put a bunch of code in the Windows Service to automatically handle fauled services by aborting them and restarting them.  As well as I've had to make a wrapper around my WCF client to automatically retry hitting the workflow services to account for if they are faulted.  I'm handling the faults / restarting the services in the WorkflowServiceHost.Faulted event.  One of the problems I've had is that the Faulted event has no details about what caused the fault.  No exceptions or anything.  Many times workflows fault due to bugs in the actual workflow design, and those exceptions are captured by workflow tracking.  However, randomly in my logs, there will be service faults with no additional exception data.  Today I hit that in the debugger for the first time, and I was able to figure out that there indeed is an exception somewhere in the object, but it's a private property!  This is the exception I'm getting:

    [System.Runtime.Persistence.InstanceOwnerException]: {"The execution of an InstancePersistenceCommand was interrupted because the instance own

WorkflowApplication.Run, SqlWorkflowInstanceStore and Delay Activity not resumed(?)

Hi all, 

I am trying to leverage the persistence on our own BPM application built upon BETA 2 of WF. We have a WCF service that accepts external "RunWorkflow" requests, that, in turn (on the WCF method implementation) create the WorkflowApplication, loads designed XAML, and runs the workflow itself.

I added a Delay activity and added SqlWorkflowInstanceStore instance. Basically on my logs, I see that the Workflows runs fine until Delay activity is reached. The Workflow gets Unloaded correctly but is never resumed.

Obviously I installed and configured the  Workflow Management Service correctly (I suppose) by making it point my instance database, where the appropriate scripts have been executed.

Looking at the  SQL Profiler, I see activity of the Management Service. 

I tried to look into the [System.Activities.DurableInstancing].CommandQueueExecutionLogTable and  [System.Activities.DurableInstancing].CommandQueueTable are empty.

The table 

Contains some rows (at each new worfklow appends a new instance and this is fine)... however wiht the "ExecutionStatus" set

Question on WorkflowApplication class design ( Func Properties)





I found out that the Workflow Application class offers Func<T> properties to inject code for example when a error occurs.

whats the reason behind the Design Decission of giving the WorkFlow Foundation class Func<T> properties instead of event?


For Example


 Func<WorkflowApplicationUnhandledExceptionEventArgs, UnhandledExceptionAction> OnUnhandledException { get

; set

; }





 Action<WorkflowApplicationCompletedEventArgs> Completed { get

; set

; }


Is it just to prevent the multiple receipients ?

Or is it related to memory mangement due to fix pins caused by eventhandlers ? To be honest i must confess that i'm not sure wether Func<T> will created a fix pin in memory :-(

I'm not sure about if this is good or not, but it would be very nice to get knowledge of the reason why this class is event

How can you invoke a Workflow from within a running WorkflowApplication?


Our app has this concept of being able to "embed" workflows inside other workflows.  So, we have a custom activity called EmbedWF.  In the EmbedWF's execute handler, we are essentially loading the XAML workflow definition of a particular workflow ... and then we need to invoke it, or run it. 

The parent workflow is hosted in a WorkflowApplication instance ... it uses persistance, navigation, etc.  The idea is that when it executes and comes to an instance of an EmbedWF activity, we want to then kick off that other embedded workflow. 

Is there a good way to do this? 

I've tried this (from the Execute event of the EmbedWF activity):

          WorkflowInvoker wfi = new WorkflowInvoker(activity);
          IDictionary<string, object> resultArgs = wfi.Invoke(args);


But that's just causing the workflow application to hang when it's running UI activities.  I've also tried this:

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