I have a custom workflow action derived from SequenceActivity

  protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
            var current = SPContext.Current;
            //current is null

The code I copied is largely from another custom action, which is working as expected. I definitely missed something when copying things over and creating the new action, but I am not sure where to look.

  • There are normally 2 places to check: your Custom Activity and your .actions file. See my answer here stackoverflow.com/a/1257293/98933
    – Kit Menke
    Commented Aug 21, 2013 at 18:52
  • Kit, I checked out your suggestion. I added a Dependency prop for context and a parameter in the .actions file. The "Context" dependency property is null when I step into the action's Execute method. Could there be something I am missing higher up? Commented Aug 21, 2013 at 20:12

1 Answer 1


the problem your getting is correct and should be null ;) why? because workflow run under different thread to the current context ;) so instead of SPContext.Current you need to use WorkflowContext!



public static DependencyProperty __ContextProperty = System.Workflow.ComponentModel.DependencyProperty.Register("__Context", typeof(WorkflowContext), typeof(YourActivityClass));

 public WorkflowContext __Context
         return ((WorkflowContext)(base.GetValue(YourActivityClass.__ContextProperty)));
         base.SetValue(YourActivityClass.__ContextProperty, value);

more details on the above code is here:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.