I've been plagued by an error with resuming workflows in a rather complex system and so far had very little luck finding a solution to it.
The error happens when I resume a workflow. The workflow and the activities have changed but there is versioning in place that shouldn't affect that. The resume operation brings out the old version of the xaml file and calls the old version of those activities and that has been working well for a year now.
Started testing a new version of the system and suddenly I get this error: The instance 'some guid' was found in the instance store, but the instance is not a workflow instance
This happens in the Resume method of worklfow and in particular in this line :
application.Load(resumeContext.WorkflowInstanceId);
In the database I can find the instance with that Guid and it looks okay so I can't understand why it wouldn't load.
I found only one page in the entire google with this error and there's no answer to it, so it's the desert out there.
The stack trace is useless:
Exception: System.Exception: Exception of type 'System.Exception' was thrown.
at System.Activities.WorkflowApplication.ExtractRuntimeState(IDictionary`2 values, Guid instanceId)
at System.Activities.WorkflowApplication.ProcessInstanceValues(IDictionary`2 values, Object& deserializedRuntimeState)
at System.Activities.WorkflowApplication.LoadCore(DynamicUpdateMap updateMap, TimeoutHelper timeoutHelper, Boolean loadAny, IDictionary`2 values)
at System.Activities.WorkflowApplication.Load(Guid instanceId, TimeSpan timeout)
at System.Activities.WorkflowApplication.Load(Guid instanceId)
at Project.TS.Services.Workflows.Hosting.ActivityInvoker.Resume[TResponse](WorkflowApplication application, InstanceStore instanceStore, ResumeBookmarkContext`1 resumeContext, IDictionary`2& outArguments)
in c:\Projects\TS\trunk\Services\Workflows\Hosting\ActivityInvoker.cs:line 186
Some more info. The way it works is the operation object contains the workflow version, name and actual Xaml and this gets loaded into a workflow application and gets invoked:
var workflowDefinition = activityResolver.Resolve(new WorkflowIdentity(operation.WorkflowVersion, operation.WorkflowName, operation.WorkflowXaml));
var application = new WorkflowApplication(workflowDefinition.Implementation);
response = activityInvoker.Resume<ResumeOperationResponse>(application, instanceStoreProvider.Create(), resumeContext, out outArguments);
Inside the invoker the resume method does this and fails:
public TResponse Resume<TResponse>(WorkflowApplication application, InstanceStore instanceStore, ResumeBookmarkContext<ResumeOperationRequest> resumeContext,
out IDictionary<String, object> outArguments)
where TResponse : ResumeOperationResponse, new()
{
var response = new TResponse();
outArguments = new Dictionary<string, object>();
IDictionary<string, object> wfOutArguments = new Dictionary<string, object>();
application.InstanceStore = instanceStore;
try
{
application.Load(resumeContext.WorkflowInstanceId);
}
catch (Exception exp)
{
//Exception happens here
}
}
At this point I'm interested in pointers in what could be causing this.
There seems to be no way to debug it and get to the actual cause of the problem.
Many thanks