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

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

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

Posted By:      Posted Date: September 28, 2010    Points: 0   Category :Windows Application

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.

View Complete Post

More Related Resource Links

Resuming of workflows from InstanceStore in Workflow 4.0 Release Candidate

Hi,  I am using the WorkflowApplication object to invoke the Workflows. In this type of invokcation, after the workflow persisted,  in case of delay activity, in beta 2 there is no support to autmatic invocation in case of expiry of timers. But in case workflowservicehost the WWF invokes the expired timers workflow instrances automatically.  When I posted the same to forums some time back, I got answer that in the  Release Candidate Mcrosoft will be providing the support of for automatic invocation even the workflows are invoked through the workflow application object.  Now I am using Custom batch job for doing the same. Please let us know about this scenario. If Microsoft provides the support please let me know the process. If there is no automatic invocation support, Can we expect in future?Thanksrajeevkalyan

Custom InstanceStore and WF service (xamlx)

I tried to use XmlWorkflowInstanceStore from WF_WCF_Samples(Application\PurchaseProcess) with my WF Service but I get exception on the client side after invoking a service method - Expected Process received null. (Process is my received operation name) I have debugged the XmlWorkflowInstanceStore.TryCommand and for the LoadWorkflowCommand my workflow is loaded from database to context (InstancePersistenceContext) - method ends without any exception - but on the client side i get received null exception. Can someone tell my what i'm doing wrong? Do i have to set some other context arguments? Are there any guidlines for writing a Custom Instance store ( i can't find any decent tutorial)udione

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

Implementing custom InstanceStore



There are a bunch of InstancePersistenceCommand derived commands that could be "executed" against the store. I can't find documentation that answers questions like:

- Which commands *must* be handled by a custom instance store?

- What is the "contract", expected behavior for each command?

- How are errors to be handled and reported to callers?

I've looked at the XmlWorkflowInstanceStore but it does not give the whole picture.

Thank you.

tjk :)

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.

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

ManualWorkflowSchedulerService.RunWorkflow(instanceID) returns false?


Hi, all


Currently I'm implementing a statemachine workflow in asp.net, most of time it works very well. But if I recompile the whole application and try to reactive persisted workflow instance from a middle state, ManualWorkflowSchedulerService.RunWorkflow(instanceID) just returns false, nothing happens, no exception, state would not changed. I have to raise the external event again, and then it will work correctly. I've already subcribed all the available events for the workflow runtime instance and tried to log something, but I found if ManualWorkflowSchedulerService.RunWorkflow(instanceID) returns false, only the Load event was triggered, I just cannot find any exception. So what I am wondering is that how can I dig deep to get more useful information to locate the potential error? Any suggestions or comments are highly appreciated.





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.



Correlation, persistence and WorkflowServiceHost conspire to give a NullReferenceException

Hi there,

In the thread at:

I was advised that I should use the WorkflowServiceHost to get Delay working in a persisted Pick. In trying to get that done, I have come across another problem.

I now have a simple WCF client that sends messages to my System.ServiceModel.Activities.WorkflowServiceHost. I have SQL persistence configured, and I have it set to unload instances after a 5 second timeout.

I have the client send messages with an instance-specific ID, and I have correlation set to use this ID to pick the proper instance.

The persisting seems to work (there's something in the Instances' XmlData column that looks appropriate).

The correlation seems to work (messages do go to the proper instance).

But it all falls apart when the instance is unloaded.  If I send a message before the instance is unloaded, it's (repeatedly) handled properly. If it's unloaded, I get the following exception:

System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: Object reference not set to an instance of an object. (Fault Detail

WorkflowServiceHost Déjà vu


I figured out that .NET 4.0 provides two WorkflowServiceHost implementations. One is in System.ServiceModel.Activities (System.ServiceModel.Activities) and another one in Syste.ServiceModel (System.WOrkflowServices).

The first one seems to be used in self hosted services (at least in provided examples), but the second one is instantiated by WorkflowServiceHostFactory.

What is the startegy behind theses two implementations, what are differences?


WorkFlowApplication vs WorkflowServiceHost


  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.

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