Problem in persistence of workflow hosted in WCF service





    I have WCF Service hosted in IIS. I have created a custom ServiceHost and ServiceFactory as follows:

    class CustomServiceHost : ServiceHost


    public CustomServiceHost(params Uri[] baseAddresses)

    : base(typeof(HMService), baseAddresses) { }


    protected override void InitializeRuntime()


    WcfWfExtension extensionObject = new WcfWfExtension();





    public class CustomServiceHostFactory : ServiceHostFactory


    protected override ServiceHost CreateServiceHost(Type serviceType,

    Uri[] baseAddresses)


    ServiceHost serviceHost = new CustomServiceHost(baseAddresses);

    return serviceHost;




    I have also created a class which is inheriting from

    IExtension<ServiceHostBase>, IDisposable.

    I am creating the instance of WorkflowRuntime in this class and adding WorkflowPersistence Service and WorkflowTracking Service into it in this class.


    Now the problem is that my workflow is being tracked properly but not getting persisted. What could be the reason, any hint?


    Thanks in advance,

    Wednesday, May 16, 2007 5:05 AM


  • Hello,


    No Dinesh, I have resolved the problem, the problem was only that I hadn't decorated my Class of Custom Data Type as Serializable.


    Thanks for asking,

    Tuesday, June 19, 2007 6:59 AM

All replies

  • As I did some more investigation to find out the root cause of the problem, I found that It is occuring because I am trying to send data to workflow through Dictionary object at the point while creating instance of workflow. If I remove that thing  means not passing the data to workflow while creating instance of workflow, it's get persisted properly.


    But I need to pass the data to workflow. So what I did is that instead of sending data to workflow through Dictionary Object, I am sending it through the custom event args by firing event on Workflow, but again when I am trying to send the data through custom event args which is basically inheritted from ExternalDataEventArgs, that event is not getting delivered. Insted if I am firing an event which has only  ExternalDataEventArgs, it's working fine.


    The overall problem, as I see is that whenever I am trying to send some data to workflow, it's creating problem.


    The same thing I did in another sample in which I took Windows form as my Workflow host, everything is working fine. Is there any setting need to be done while hosting the Workflow in WCF service?????


    Please help on it. Let me know if further clarfiaction is required.


    Thanks in advance,

    Wednesday, May 23, 2007 9:07 AM
  • Hi


     Even I am facing the same problem, sending data to the workflow, the scenario is same as kanhaiya have mentioned above,

    Please suggest if we are missing any point and if theres a solution for this..


    Thanks  in advance



    Monday, May 28, 2007 2:20 PM
  • You need to make sure your ExternalEventArgs derived class is marked as Serializable.
    Monday, May 28, 2007 4:15 PM
  • Thanks Jon,


    But I have checked it, that class is already marked as serializable. As I have mention in my previous post is that I have done the same and it's working when I am hosting my workflow in Windows application. Also When I am trying to send the data to the workflow hosted in WCF through dictionary<> object, then it's creating problem and workflow is not getting persisted, here I am just trying to send the string which is by default serializable.



    Tuesday, May 29, 2007 6:26 AM
  • Hey Kanhaiya, Can you share the code base to debug the problem? I am specifically looking for how are you setting up the workflowruntime and dispatching messages to it.


    Thanks, Dinesh.

    Tuesday, May 29, 2007 6:53 PM
  • Hey Kanhaiya, Are you still seeing issues here?


    Tuesday, June 19, 2007 5:13 AM
  • Hello,


    No Dinesh, I have resolved the problem, the problem was only that I hadn't decorated my Class of Custom Data Type as Serializable.


    Thanks for asking,

    Tuesday, June 19, 2007 6:59 AM