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.

你可能感兴趣的:(SharePoint)