none
Custom Activity GetService<T>() returns NULL when more than one PS workflow is deployed to a single server RRS feed

  • Question

  • This issue has been a real hard one to track down and has been causing me huge issues in a number of environments, I'm leaning towards it being a bug of some kind, but would appreciate if anyone was able to confirm / advise based on my findings.

    Summary:

    When creating a custom workflow activity implementing PSI services (such as in the SDK sample Samples\Workflow\CustomActivity:http://msdn.microsoft.com/en-us/library/ms512767(office.14).aspx) if you deploy multiple different workflow solutions each using their own separate custom activities to a single server then only ONE solution will ever work.

    Scenario:

    1. Install the above SDK sample.
    2. Install the DMDynamicWofklow Solution Starter.
    3. Create workflows and EPT's for both of the above on two separate web apps hosting PWA in the same farm, each PWA instance only has one of the two workflow solutions installed. (I think the same applies if both are installed on the same PWA instance, but I have not tested this).
    4. Ensure that your DMDynamicWorkflow workflow has an approval activity defined (as this uses a custom activity).
    5. Create a project on both PWA instances and run through the workflow.

    The result is that the 2nd project will fail (assuming you only have one server in the farm with Project Services enabled) with the following error in the ULS:

    System.NullReferenceException: Object reference not set to an instance of an object.   

     at ActivityLibrary.GrantPermissionsToProject.Execute(ActivityExecutionContext executionContext)   

     at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(T activity, ActivityExecutionContext executionContext)   

     at System.Workflow.ComponentModel.ActivityExecutor`1.Execute(Activity activity, ActivityExecutionContext executionContext)   

     at System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime)   

     at System.Workflow.Runtime.Scheduler.Run()

    The above is assuming that the SDK sample was the failing one but the error from the solution starter is essentially the same just the second line is different:

     at DemandManagement.ApprovalActivity.Execute(ActivityExecutionContext executionContext)   

    My testing indicates that the first workflow run always will work and continue working until the next IISRESET, however the second one will never work!

    From the SDK sample the line of code throwing the exception thrown by GetService in:

    protected override ActivityExecutionStatus Execute(            ActivityExecutionContext executionContext)
            {
                ICustomWorkflowService wfService = 
                    executionContext.GetService<ICustomWorkflowService>();

    Specifically although executionContext is otherwise correct, the GetService always returns NULL resulting in the exception further down the line.

    Can anyone confirm this or otherwise help with this one? I have tested in three different environments (Small, Medium and Large farm deployments) and it is consistent across all.


    Martin Laukkanen (Project Server Blog - www.nearbaseline.com/blog)


    Thursday, March 1, 2012 9:25 AM

All replies

  • I have come accross this as well and am currently searching for a resolution. 

    kam

    Wednesday, March 14, 2012 12:42 AM
  • Resolved: I forgot to update the web.config.  If you look at the Solution Starter, you'll see a feature event receiver that configures the web.config to list your proxy as a workflowservice under  <WorkflowServices>


    kam


    • Proposed as answer by K McVay Wednesday, March 14, 2012 1:08 AM
    • Edited by K McVay Wednesday, March 14, 2012 1:09 AM
    • Unproposed as answer by Martin Laukkanen Wednesday, March 14, 2012 3:04 AM
    Wednesday, March 14, 2012 1:08 AM
  • Hi Kam,

    Thanks for your input, yes I see now where my scenario above failed thanks I've just tested and I had forgotten to add the WorkflowService to the SDK solution, once I did that now both solutions run on the same farm.

    Unfortunatly this doesn't solve my actual issue but only my attempt to reproduce it using publically available code! I still get the same issue when using my own custom developed WorkflowActivities when running on the same farm as the DMDynamicWorkflow solution, in fact I have a few custom workflows developed for different customers and only ONE of them will ever work at the same time on my Dev server (or Staging farm).

    I will however retest everything just to be absolutely sure as even though I'm using a FeatureReciever in all my solutions maybe something is different.

    Thanks,

    Martin


    Martin Laukkanen (Project Server Blog - www.nearbaseline.com/blog)

    Wednesday, March 14, 2012 3:04 AM