.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

Why did my workflow execute twice the same instance?

Posted By:      Posted Date: October 04, 2010    Points: 0   Category :SharePoint


I'd like to understand why is happening this. I'm designing a workflow in SPD, and the same workflow run twice!

Look that "Workflow Completed" is presented twice in the Workflow History.

What is happening? I made some wrong configuration?

I'm trying to update some fields in a list after item update (the workflow A is started after item update), so to avoid loops I created an auxiliary list:

On item update in List A it is started the workflow A that creates an item for each operation in the auxiliary list that starts an workflow B on item creation to update the item in list A...

When the Workflow B tries to update the item, the workflow A is started again, but I added a condition: if there is an item in auxiliary list so this workflow had already executed then the item in auxiliaty list is deleted and worflow stopped. But it didn't stop and it run again as you can see in history:


04/10/2010 08:59 Comment

View Complete Post

More Related Resource Links

Can I dehydrate the Workflow object as well as the instance?

Hiya All Can I dehydrate the workflow object (i.e. not an instanciation of it) into SQLServer?  I want to save all versions created of a workflow so that I can chose to instanciate the workflow from any of the previous versions if I need to. This is due to a compliancy issue - being able to reconstruct the data created by a previous version of a workflow to prove accuracy. ThanksMichelle x

Is there a way to check if workflow instance already exists for a particular productID in Workflow o

I am using Visual Studio 2008 and .NET 3.5. I am trying to build a WF that is exposed as WCF hosted on IIS. This service is consumed by ASP.NET client. It is a very simple WF- receive info for new product "A"- send email to person 'Xyz' that new prodcut "A" is received- do some business process for product "A"- send out more notifications for product "A"Consider this scenario - - Client hits submit on asp.net page for prodcut "A"- new WF instance is created for product "A"- client can go back to the same page, edit some more info and hit save again. However, this time or for any subsequent "Saves",  I do not want to create a new WF instance for product "A".I can check to see if a WF instance exists for product "A" on the client side before calling the service operation. However, I want to see if there is a way to do this in WF or WorkflowServiceHost, as I don't want to add this logic to client. First acitvity in WF has to be receive activity with CanCreateInstance = true, so not sure how I can do this check in WF itself.Also, I have another stupid question, when using WF exposed as WCF service, do we have to implement all service operations using WF? What if I have some service operations that just involves checking some business logic? Do I implement this in a

System.InvalidOperationException: Instance operation is not valid on workflow runtime thread

Am getting the exception related in the title of this article when using the StateMachineWorkflowInstance object to arbitarily set state in my workflow code; and am unsure why.  The code follows below:   500     Protected Overrides Function Execute(ByVal executionContext As System.Workflow.ComponentModel.ActivityExecutionContext) As System.Workflow.ComponentModel.ActivityExecutionStatus   501    502    506         Dim smwi As StateMachineWorkflowInstance = New StateMachineWorkflowInstance(StaticWFRuntime.LocalRuntime, Me.WorkflowInstanceId)   511    512         'set workflow-wide database connection string   513         _connectionString = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString   518    519         Utility.LogEnabled()   520    521         Utility.FoaeaLogger.WriteEntry("Processing TracingApplication.Execute()....", EventLogEntryType.Information)   522         If StaticWFRuntime.LocalRuntime Is Nothing OrElse StaticWFRuntime.LocalRuntime.IsStarted = False Then   523             Utility.FoaeaLogger.WriteEntry("No static RuntimeService object exists!", EventLogEntryType.Warning)   524         End If   525    526         Return MyBase.Execute(executionContext)   527    528     End Function   796     Private Sub gotoState2_ExecuteCode(ByVal sender As System.Object, ByVal e As System.EventArgs)   797    798        

Any way to execute a workflow when a caml query returns zero items?

Lets say I have a list with a status column and I want to execute a workflow when all items in the list have a status of complete. I basically want to execute a workflow when the caml query looking for non-complete statuses returns zero rows. Can I do this with SPD or are there any 3rd party tools for this? I'm thinking of writing one if there are not.

Workflow Instance ID field in MS Access

Hello, please help! When I open a SP list with MS Access (Action > Open with Access), the Workflow Instance ID field is available with no data.  How can I get this field to display so I can create queries within MS Access using joins/relationships?  Thank you!

Workflow project compilation fails with error 348: Compilation failed. Cannot execute a program.

Hi, I am trying to build a workflow project on a PC and I am getting the "error 348: Compilation failed. Cannot execute a program." error. This project is part of a bigger solution and it used to build just fine on my PC. Also, the project and the solution build OK on several other computers. I am sure that the problem is something on my PC. 1. I am not sure what changed to make the project start failing. 2. I tried to delete the project, source and all folders from the disk and sync to the source control again 3. Re-installed the .NET 3.5 framework 4. Uninstalled Visual Studio 2008, deleted the visual studio folder under program files, and reinstalled VS 2008 5. I noticed the the file referenced in the error "...Temp\8sl_helt.cmdline" does not exist under the Temp folder. An empty folder called "8sl_helt"however is created, but there is no file with the cmdline extension. I turned up the output log to "diagnostics", this is the output generated when the error happens. Have anybody seen this? Done building target "_ComputeNonExistentFileProperty" in project "QCReviewWorkflowLibrary.csproj". Target "CreateWorkflowManifestResourceNames" skipped. Previously built successfully. Target "WorkflowCompilation" in file "C:\Program Files\MSBuild\Microsoft\Windows Workflow Foundation\v3.5\Workflow.T

Object per workflow instance via Extension


I have been trying unsuccessfully to create an extension that will allow me to supply a new instance of a object to each workflow instance.  Specifically, I am attempting to supply a variant of the UnitOfWork class used to managed long running NHibernate ISsessions.  I keep hearing that you can add a service behavior extension on a per-workflow instance basis, but none of the examples I’ve seen show you how.  When I attempt to retrieve the extension in my Activity, I always get the same singleton instance.


public class UnitOfWork : IUnitOfWork


        public Dictionary<string, ISessionFactory&

Workflow instance id from wsHttpContextBinding vs database InstanceTable.Id


I'm working with SqlWorkflowInstanceStore and i'm using wshttpcontextbinding to get workflow instance id for corellation of workflow requests:

IContextManager oContextManager =


string oInstanceId = oContextManager.GetContext()["instanceId"];

but oInstanceId does not map to value of column "Id in System.Activities.DurableInstancing.InstanceTable. Can anyone tell me how to get row of InstanceTable using "instanceId" form IContextManager?


Get the current workflow instance ID in a WF4 workflow service


Is it possible to somehow query the current workflow instance ID (or another unique identifier) within code executed as part of a workflow service?


public sealed class SomeCodeActivity : CodeActivity
  public InOutArgument<List<string>> Messages { get; set; }

  protected override void Execute(CodeActivityContext context)
    var logger = new SimulatedLogger();

public class SimulatedLogger
  public void CreateLog(IList<string> messages)
    //This line throws an exception

Execute a custom workflow after a out of box the workflow

Does anyone know how to trigger a custom workflow after a out of the box workflow (for example, approval workflow has been approved or rejected).  

The only solutions I can think of at the moment are -

a) Complete custom workflow does everthing
b) Start both workflows on item creation, the custom workflow then keeps checking after x mins or x hours to see the status of the approval workflow? 

I was hoping that there might be a way to listen on an event of the approval workflow within the out of the box workflow.  Any ideas appreciated I cannot seem to find any history of anyone trying to do this.

Dynamically get the current instance of the workflow within a re-hosted WPF application



the scenario is: I create a re-hosted WPF application for the workflow designer, and within this designer I can edit the workflow(sequence, flowchart) with pre-defined and custom activities. The question is, how can I programmatically get an instance of the current workflow. Thereafter I can do some manipulations on this instance.



Sharepoint Workflow - Object Reference Not Set to an instance of an object



I create a Custom Sharepoint workflow using VS 2008. Let me go step by step:

1. I have an infopath form which is a requisition form.  I saved all my infppath source class and other custon class files in a Class library.

2. I built this class library and assigned a string key to it.

3. created a custom sequential workflow and added my class library dll to this workflow.

4. In my workflow I have a function where I am using :

                    using (SPSite currentSite = new SPSite(siteURL))
                        using (SPWeb currentWeb = currentSite.OpenWeb())

Single instance of workflow for a parameter



I'm a newby to WF fnd have a question which I haven't found an answer for:

I've got a WCF workflow service which is invoked by receive activity with a parameter (saleId). My workflow is a long running workflow and I want only a single instance of a workflow to be running for the saleId.

I tried to implement it with correlation mechanisms, however I receive an exception, when starting the secong workflow with the same parameter The execution of an InstancePersistenceCommand was interrupted by a key collision. The instance key with value '{Unique ID}' could not be associated to the instance because it is already associated to a different instance.

And after this exception the execution of the first workflow stops together with the second one.

Extension instance management for workflow service


I have written some custom activities for business validation (http://www.neovolve.com/post/2010/10/13/Custom-Workflow-activity-for-business-failure-evaluatione28093Wrap-up.aspx with project source at http://neovolve.codeplex.com/SourceControl/changeset/view/68064#1422354). They have worked fine until I use them in a workflow service.

The evaluator activity pushes a business failure into a custom extension. The custom extension will then detect whether the evaluator is contained in a scope activity. If there is a scope activity, it will store the failure in the extension for the scope to collect later. If there isn't a scope, it will throw an exception straight away. The scope will look for failures in the extension written by its child activities when it completes and will throw an exception for the set of failures.

This has worked fine so far for workflows executed via WorkflowInvoker and WorkflowApplication. There are unit tests for these activities to ensure that the above behavior is working as expected.

I have just used these activities in a workflow service and found that the extension behavior is very different. The function p

How to share a single workflow instance across diff pages of asp.net application..?



I am using WWF 3.0 with ASP.Net application with two pages of form submission and approval.

The submission form instantiates, starts the workflow and completes half part of the workflow. In the approval page the suspended workflow has to be resumed to get completed(throught HandleExternalEvent Activity). In this case how i can use the same workflow instance between two different aspx pages..?


execute a winform application within a seq workflow


I have a need to run programmatically, a winform application in the ExecuteCode task in my Sequenctial Workflow.

It's not working. The application doesn't initiate. Moving the same code to a winform application works fine.

Is this possible to work? I thought maybe if I created a new AppDomain in the ExecuteCode it might work. It is required that the GUI on nthe server when running the workflow.. I know it's a bad idea, but I don't have a choice.


It's not a great idea, but it has to be done somehow.



How to get workflow instance in custom activity?


I am using Sequential workflow (.net 3.5). I have created 3 custom activities and dragged these activities in my sequential workflow. The activities are




Each Custom activity will have the following execute method. 

protected override ActivityExecutionSt

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