Error occurred in deployment step 'Activate Features':
Object reference not set to an instance of an object. This is a common Error
that every SharePoint developer will do.
We cannot use SPContext.Current.Web in feature
receivers. They can be run by the timer service or powershell which does not
have access to the SPContext.
So We can create instances for out SPsite and SPWeb as
mentioned below.
using (SPSite
site = (SPSite)properties.Feature.Parent)
{
using (SPWeb web = site.OpenWeb())
{
Our code
---------------------
---------------------
---------------------
}
}
No comments:
Post a Comment