SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
There are normally 2 places to check: your Custom Activity and your .actions file. See my answer here – Kit Menke Aug 21 '13 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? – SharepointHater Aug 21 '13 at 20:12
up vote 1 down vote accepted

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:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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