Sharepoint timer job:Object reference not set to an instance of an object

When created a custom timer job in sharepoint 2010. I receive the famous "Object reference not set to an instance of an object" error on the very first line of the Execute() method.

 

Using(SPsite site = spcontext.current.site.ID)

{

using(spweb web = site.openweb()

}

When a timer job runs there is no SPContext.Current. You can try using this.WebApplication to obtain the current web application that the timer job is running against.

posted @ 2012-05-02 16:19  大刀客  阅读(286)  评论(0编辑  收藏  举报