Persisted Worklow won’t resume

Lately I have been assigned to work with the Windows Workflow Foundation.

My feelings about it are mixed. There was a bug, that hold me for one day and I want to share with you, a troubleshooting technique that helped me.

First of all, out runtime service need to be persisted. In order to test persistance with Workflow out of the box activities, just create a while (true) activitiy with a seqeunce activity with a delay and something that can be debugged. I have create a Debug Activity.

The runtime is initialized with an sql persistance service like this

NameValueCollection persistenceParams = new NameValueCollection();
persistenceParams.Add("ConnectionString", ConnectionString);
persistenceParams.Add("UnloadOnIdle", Convert.ToString(true));
persistenceParams.Add("LoadIntervalSeconds", "5");

this.runtime.AddService(new SqlWorkflowPersistenceService(persistenceParams));
Every time a delay or a timer is reached because of UnloadOnIdle, it will be persisted.
My problem was that the workflow never resumed although, the entries in the database were correct.
I monitored its flow, by capturing these events
  • WorkflowIdled
  • WorkflowSuspended
  • WorkflowUnloaded
  • WorkflowPersisted
  • WorkflowLoaded

But WorkflowLoaded never came through. The reason I know it should was because I was actually refactoring I knew the sequence of events that would be fired.

Finally, and after some time I decided to capture ServicesExceptionNotHandled event. It turns out that although you may have declared to capture all exceptions form Visual Studio (Ctrl+Alt+E), if you do not capture that event you will never know what’s wrong.

The event provides a ServicesExceptionNotHandledEventArgs that basically holds the exception of what wen’t wrong.

In my case the problem was with serialization. The actual problem I will discuss in my next post.



One comment

  1. Pingback: Serializing « Alex Sarafian as Developer

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s