locked
Please, Help! RRS feed

  • Question

  • I am about to loose the ability to Windows WorkFlow because a simple problem I cannot seem to figure out and knowbody can seem to answer.

    Its simple, how do I get the service objects right after a workflow is coming back from being persisted?

    mardo
    Tuesday, June 20, 2006 10:53 PM

Answers

  • Have you tried the WorkflowLoaded event?  Add the following where you create the workflow runtime:

     

    workflowRuntime.WorkflowLoaded += new EventHandler<WorkflowEventArgs>(workflowRuntime_WorkflowLoaded);

     

    Below is an example of how to get the Sql persistence service in the handler:

     

    static void workflowRuntime_WorkflowLoaded(object sender, WorkflowEventArgs e)

    {

        WorkflowRuntime workflowRuntime = e.WorkflowInstance.WorkflowRuntime;

        SqlWorkflowPersistenceService sqlPersistence = workflowRuntime.GetService<SqlWorkflowPersistenceService>();

    }

    Tuesday, June 20, 2006 11:08 PM
  • If you need the service within your activity, override the OnActivityExecutionContextLoad method which gets passed an IServiceProvider interface that you can query for services. 

    Matt

    Wednesday, June 21, 2006 1:48 AM
  • You won't have to rebuild the whole workflow. 

    1. Remove the current visual studio extensions for workflow (and the Orcas CTP if you have those). 
    2. Remove the feb ctp of the windows sdk
    3. Remove the winfx runtime components. 
    4. Restart for good measure.
    5. Install the winfx runtime components
    6. Install the windows sdk
    7. install the wf vs extensions
    8. install the orcas extensions if you want them. 
    9. OPen your workflow solution, clean and build. 

    the biggest thing you'll likely have to change is to make your fields and properties that are bound to into public.  Other than that there were some name changes, but it shouldn't take long to update. 

    I've updated a lot of workflows from the feb build to the may build with very little problem. 

    Matt

     

    Wednesday, June 21, 2006 11:48 PM

All replies

  • Have you tried the WorkflowLoaded event?  Add the following where you create the workflow runtime:

     

    workflowRuntime.WorkflowLoaded += new EventHandler<WorkflowEventArgs>(workflowRuntime_WorkflowLoaded);

     

    Below is an example of how to get the Sql persistence service in the handler:

     

    static void workflowRuntime_WorkflowLoaded(object sender, WorkflowEventArgs e)

    {

        WorkflowRuntime workflowRuntime = e.WorkflowInstance.WorkflowRuntime;

        SqlWorkflowPersistenceService sqlPersistence = workflowRuntime.GetService<SqlWorkflowPersistenceService>();

    }

    Tuesday, June 20, 2006 11:08 PM
  • If you need the service within your activity, override the OnActivityExecutionContextLoad method which gets passed an IServiceProvider interface that you can query for services. 

    Matt

    Wednesday, June 21, 2006 1:48 AM

  • I cannot override this (it does not show up as a declaration)..

    I am using v2.0.50727.

    Mardo
    Wednesday, June 21, 2006 8:12 PM
  • The version number you are giving if for VS, not Windows Workflow Foundation.  Go to %programfiles%\Reference Assemblies\Microsoft\WinFX\v3.0 and give the version of System.Workflow.Activities.dll.  I don't have a computer with Beta 2 installed, but the method exist with Beta 2.2.
    Wednesday, June 21, 2006 8:26 PM
  • 3.0.03603.6.  Is this a new declaration?
    Wednesday, June 21, 2006 9:17 PM
  • Yes, this is new in Beta 2.2 which is file version 3.0.3807.7.  You'll want to upgrade for this and other improvements.  Beta 2.2 is part of the May release of WinFx Runtime Components, otherwise known as Beta 2 of the Runtime components along with Beta 2 of Vista, etc.  Check here [1] for the latest bits. 

    Matt

     

    [1] http://msdn.microsoft.com/windowsvista/downloads/products/getthebeta/

    Wednesday, June 21, 2006 9:36 PM
  • This is not good! I have built a whole workflow on the Beta 2 and I need the runtime of beta 2! Is there a possiblity to get the runtime from another download link, because otherwise I would have to get the SDK's and the Visual Studio Extensions for Beta2.2 too and I would have to rebuilt the whole workflow!

    Please help!

    Peter

     

    Wednesday, June 21, 2006 11:02 PM
  • You won't have to rebuild the whole workflow. 

    1. Remove the current visual studio extensions for workflow (and the Orcas CTP if you have those). 
    2. Remove the feb ctp of the windows sdk
    3. Remove the winfx runtime components. 
    4. Restart for good measure.
    5. Install the winfx runtime components
    6. Install the windows sdk
    7. install the wf vs extensions
    8. install the orcas extensions if you want them. 
    9. OPen your workflow solution, clean and build. 

    the biggest thing you'll likely have to change is to make your fields and properties that are bound to into public.  Other than that there were some name changes, but it shouldn't take long to update. 

    I've updated a lot of workflows from the feb build to the may build with very little problem. 

    Matt

     

    Wednesday, June 21, 2006 11:48 PM
  • This did the trick, thanks!

    Thursday, June 22, 2006 8:50 AM