Careful with SPContext.Current…

...as it will be NULL within a Timer Job or Workflow. I have some shared Data Access classes that use SPContext.Current.Web all over the place and now that I want to use them from within a Timer Job, I have to refactor them to take a SPWeb as a Parameter...

Comments (2)

ScarePoint360January 10th, 2012 at 16:06

So are you going to create Fake SPContext.Current OR make the Timer Job execute in SharePoint's context?

mstumJanuary 10th, 2012 at 17:20

Neither, since there is no Context, it runs side by side with SharePoint. I have to instantiate the SPSite or SPWeb that I want myself.