Rory Primrose

Learn from my mistakes, you don't have time to make them yourself

View project on GitHub

ActivityExecutionContext failed to serialize

Posted on August 13, 2007

An exception of type ‘System.Runtime.Serialization.SerializationException’ occurred in Neovolve.Framework.Workflow.DLL but was not handled in user code Additional information: Type ‘System.Workflow.ComponentModel.ActivityExecutionContext’ in Assembly ‘System.Workflow.ComponentModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ is not marked as serializable.

This was a bit of a curly one.

The problem was caused because one of my custom activities couldn’t be serialized. The custom activity was used in a WhileActivity. Serialization is happening behind the scenes because the WhileActivity uses serialization to create clones of the activities in its loop.

Jon Flanders posted some great entries about AEC and serialization (here and here).

The moral of the story is to ensure that your custom activities can be serialized (or workarounds developed) so that WF persistence and WhileActivities can use them.