Bastiaan Molsbeck

Hello,

I've built an SQL persisting workflow hosted by an ASP.NET web application. The workflow now works almost correctly, but when the workflow is completed I receive the following error:

System.Workflow.Runtime.Hosting.PersistenceException

This workflow is not owned by the WorkflowRuntime. The WorkflowRuntime's ownership has expired, or another WorkflowRuntime owns the workflow.

at System.Workflow.Runtime.WorkflowExecutor.Persist(Activity dynamicActivity, Boolean unlock, Boolean needsCompensation)

at System.Workflow.Runtime.WorkflowExecutor.System.Workflow.ComponentModel.IWorkflowCoreRuntime.PersistInstanceState(Activity activity)

at System.Workflow.ComponentModel.Activity.MarkClosed()

at System.Workflow.ComponentModel.Activity.ReleaseLockOnStatusChange(IActivityEventListener`1 eventListener)

at System.Workflow.ComponentModel.FaultAndCancellationHandlingFilter.SafeReleaseLockOnStatusChange(ActivityExecutionContext context)

at System.Workflow.ComponentModel.FaultAndCancellationHandlingFilter.OnEvent(Object sender, ActivityExecutionStatusChangedEventArgs e)

at System.Workflow.ComponentModel.ActivityExecutorDelegateInfo`1.ActivityExecutorDelegateOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime)

at System.Workflow.Runtime.Scheduler.Run()

at System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService.System.Workflow.Runtime.IPendingWork.Commit(Transaction transaction, ICollection items)

at System.Workflow.Runtime.WorkBatch.PendingWorkCollection.Commit(Transaction transaction)

at System.Workflow.Runtime.WorkBatch.Commit(Transaction transaction)

at System.Workflow.Runtime.VolatileResourceManager.Commit()

at System.Workflow.Runtime.WorkflowExecutor.DoResourceManagerCommit()

at System.Workflow.Runtime.Hosting.SharedConnectionWorkflowCommitWorkBatchService.CommitWorkBatch(CommitWorkBatchCallback commitWorkBatchCallback)

at System.Workflow.Runtime.WorkflowExecutor.CommitTransaction(Activity activityContext)

at System.Workflow.Runtime.WorkflowExecutor.Persist(Activity dynamicActivity, Boolean unlock, Boolean needsCompensation)

Does anybody have a solution for my problem



Re: Windows Workflow Foundation PersistenceException when workflow is completed

Bastiaan Molsbeck

I solved my problem!

I needed to fill the parameter "instanceOwnershipDuration" of the constructor of the "SqlWorkflowPersistenceService" with a valid TimeSpan. I was passing a null value but when I pass a TimeSpan of -for instance- one minute, the workflow works correctly!





Re: Windows Workflow Foundation PersistenceException when workflow is completed

Jeremy Thake

What happens after this timespan if you then want to load it into an instance and raise an event for example How do you "obtain" ownership for an workflow instance





Re: Windows Workflow Foundation PersistenceException when workflow is completed

Matt Milner - Pluralsight

When the persistence service loads the workflow from SQL, it will automatically take ownership of it; you don't have to code anything specific. You control behavior by setting the timeout for this ownership.

You also need to watch for the WorkflowOwnershipException to know if another runtime instance has ownership.

Matt






Re: Windows Workflow Foundation PersistenceException when workflow is completed

shnar

I'm getting the same problem, however I have my instanceOwnershipDuration set to "TimeSpan.FromMinutes(1.0)". But at the end of each workflow, this same exception is being thrown, the This workflow is not owned by the WorkflowRuntime. The WorkflowRuntime's ownership has expired, or another WorkflowRuntime owns the workflow. Exception. Is there anything else that needs to be set to stop this exception from happening

-shnar